Here you can find the source of getElementByXPath(Element e, String xPathExpression)
public static Element getElementByXPath(Element e, String xPathExpression) throws XPathExpressionException
//package com.java2s; // it under the terms of the GNU Affero General Public License as import javax.xml.xpath.XPath; import javax.xml.xpath.XPathConstants; import javax.xml.xpath.XPathExpressionException; import javax.xml.xpath.XPathFactory; import org.w3c.dom.Element; public class Main { public static Element getElementByXPath(Element e, String xPathExpression) throws XPathExpressionException { XPathFactory factory = XPathFactory.newInstance(); XPath xPath = factory.newXPath(); return (Element) (xPath.evaluate(xPathExpression, e, XPathConstants.NODE)); }// www.jav a 2 s . c o m }