Java tutorial
//package com.java2s; import javax.xml.xpath.XPathConstants; import javax.xml.xpath.XPathExpression; import javax.xml.xpath.XPathExpressionException; import org.w3c.dom.Document; import org.w3c.dom.NodeList; public class Main { /** * @param doc * @param expr * @return * @throws XPathExpressionException */ public static NodeList findNodes(Document doc, XPathExpression expr) throws XPathExpressionException { Object evaluate = expr.evaluate(doc, XPathConstants.NODESET); NodeList nodes = (NodeList) evaluate; return nodes; } }