Java tutorial
//package com.java2s; import org.w3c.dom.NodeList; import org.xml.sax.InputSource; import javax.xml.xpath.*; public class Main { private static XPath xPath; public static NodeList getResultXpath(String expr, InputSource inputSource) throws XPathExpressionException { XPathExpression xExpr = xPath.compile(expr); NodeList evaluate = (NodeList) xExpr.evaluate(inputSource, XPathConstants.NODESET); return evaluate; } }