title: Xerces XPath causes seg fault when path doesn't exist
body: <p>I can successfully use Xerces XPath feature to query for information from an XML with the following XML and C++ code.</p>
  
  <p><strong>XML</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="no"?&gt;
  &lt;root&gt;
      &lt;ApplicationSettings&gt;
          hello universe
      &lt;/ApplicationSettings&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p><strong>C++</strong></p>
  
  <pre><code>int main()
  {
    XMLPlatformUtils::Initialize();
    // create the DOM parser
    XercesDOMParser *parser = new XercesDOMParser;
    parser-&gt;setValidationScheme(XercesDOMParser::Val_Never);
    parser-&gt;parse("fake_cmf.xml");
    // get the DOM representation
    DOMDocument *doc = parser-&gt;getDocument();
    // get the root element
    DOMElement* root = doc-&gt;getDocumentElement();
  
    // evaluate the xpath
    DOMXPathResult* result=doc-&gt;evaluate(
        XMLString::transcode("/root/ApplicationSettings"), // &lt;-- HERE IS THE XPATH
        root,
        NULL,
        DOMXPathResult::ORDERED_NODE_SNAPSHOT_TYPE, //DOMXPathResult::ANY_UNORDERED_NODE_TYPE, //DOMXPathResult::STRING_TYPE,
        NULL);
  
    // look into the xpart evaluate result
    result-&gt;snapshotItem(0);
    std::cout&lt;&lt;TranscodeToStr(result-&gt;getNodeValue()-&gt;getFirstChild()-&gt;getNodeValue(),"ascii").str()&lt;&lt;std::endl;;
  
    XMLPlatformUtils::Terminate();
   return 0;
  }
  </code></pre>
  
  <p>The problem is that sometimes my XML will only have certain fields. But if I remove the <code>ApplicationSettings</code> entry from the XML it will seg fault. How can I properly handle these optional fields? I know that trying to correct from seg faults is risky business.</p>