 <p>Try </p> <pre><code>Object result = expr.evaluate(doc, XPathConstants.NODESET); // Cast the result to a DOM NodeList NodeList nodes = (NodeList) result; for (int i=0; i&lt;nodes.getLength();i++){ System.out.println(nodes.item(i).getNodeValue()); } </code></pre>