title: Xpath - evaluate function returns javax.xml.transform.TransformerException
body: <p>This is the first time I am using XPath, and I am trying to query a very basic example.</p>
  
  <pre><code>    String xml = "&lt;resp&gt;&lt;status&gt;good&lt;/status&gt;&lt;msg&gt;hi&lt;/msg&gt;&lt;/resp&gt;";
  
      XPathFactory xpathFactory = XPathFactory.newInstance();
      javax.xml.xpath.XPath xpath = xpathFactory.newXPath();
  
      InputSource source = new InputSource(new StringReader(xml));
  
      String status = "";
      try {
          status = (String) xpath.evaluate("//resp/status", source,XPathConstants.STRING);
      } catch (Exception e) {
          e.printStackTrace();
      }
  
      System.out.println("status=" + status);
  </code></pre>
  
  <p>I receive the following exception:</p>
  
  <blockquote>
    <p>javax.xml.transform.TransformerException: Unable to evaluate expression using this context  at
    com.sun.org.apache.xpath.internal.XPath.execute(Unknown Source)   at
    com.sun.org.apache.xpath.internal.jaxp.XPathImpl.eval(Unknown Source)
      at com.sun.org.apache.xpath.internal.jaxp.XPathImpl.evaluate(Unknown
    Source)   at Heandlers.HTTP.x(HTTP.java:74)   at
    Views.Main.main(Main.java:15) Caused by: java.lang.RuntimeException:
    Unable to evaluate expression using this context  at
    com.sun.org.apache.xpath.internal.axes.NodeSequence.setRoot(Unknown
    Source)   at
    com.sun.org.apache.xpath.internal.axes.LocPathIterator.execute(Unknown
    Source)   ... 5 more
    --------- java.lang.RuntimeException: Unable to evaluate expression using this context    at
    com.sun.org.apache.xpath.internal.axes.NodeSequence.setRoot(Unknown
    Source)   at
    com.sun.org.apache.xpath.internal.axes.LocPathIterator.execute(Unknown
    Source)   at com.sun.org.apache.xpath.internal.XPath.execute(Unknown
    Source)   at
    com.sun.org.apache.xpath.internal.jaxp.XPathImpl.eval(Unknown Source)
      at com.sun.org.apache.xpath.internal.jaxp.XPathImpl.evaluate(Unknown
    Source)   at Heandlers.HTTP.x(HTTP.java:74)   at
    Views.Main.main(Main.java:15)
    --------------- linked to ------------------ javax.xml.xpath.XPathExpressionException:
    javax.xml.transform.TransformerException: Unable to evaluate
    expression using this context     at
    com.sun.org.apache.xpath.internal.jaxp.XPathImpl.evaluate(Unknown
    Source)   at Heandlers.HTTP.x(HTTP.java:74)   at
    Views.Main.main(Main.java:15) Caused by:
    javax.xml.transform.TransformerException: Unable to evaluate
    expression using this context     at
    com.sun.org.apache.xpath.internal.XPath.execute(Unknown Source)   at
    com.sun.org.apache.xpath.internal.jaxp.XPathImpl.eval(Unknown Source)
      ... 3 more Caused by: java.lang.RuntimeException: Unable to evaluate
    expression using this context     at
    com.sun.org.apache.xpath.internal.axes.NodeSequence.setRoot(Unknown
    Source)   at
    com.sun.org.apache.xpath.internal.axes.LocPathIterator.execute(Unknown
    Source)   ... 5 more status=</p>
  </blockquote>
  
  <p>Any suggestions?</p>