title: How to evaulate xpath expression using JXpath library
body: <p>I'm using apache JXPath library to parse an XML. I'm trying to find an API in JXPath which does similar function as XPath evaluate, i.e. check if the xpath expression exists ? Its similar in the lines of </p>
  
  <pre><code>&lt;xsl:when test="
  </code></pre>
  
  <p>when using xslt. Using XPath I can similarly do</p>
  
  <pre><code>XPathFactory xpathFactory = XPathFactory.newInstance();
  XPath xpath = xpathFactory.newXPath();
  InputSource source = new InputSource(new StringReader(xml));
  status = xpath.evaluate("/resp/status/solution", source);
  </code></pre>
  
  <p>If solution is not present, then it'll return status as null.
  Now,while using JXPath, I'm unable to figure an API in similar lines. Here's my sample code</p>
  
  <p>DocumentBuilderFactory dbfactory = DocumentBuilderFactory.newInstance();</p>
  
  <p>DocumentBuilder bld = dbfactory.newDocumentBuilder();</p>
  
  <p>Document metaDoc = bld.parse(in);</p>
  
  <p>JXPathContext metaCtx = JXPathContext.newContext(metaDoc);</p>
  
  <p>Node node = (Node)metaCtx.selectSingleNode("/resp/status/solution");</p>
  
  <p>This throws a "JXPathNotFoundException: No value for xpath". For implementation specific logic, I need to put and if-else block if the expression doesn't return data / doesn't exist. </p>
  
  <p>Any pointer on this will be highly appreciated.</p>
  
  <p>Thanks</p>