Here you can find the source of xpathToNode(Document document, String xpathExpression)
public static Node xpathToNode(Document document, String xpathExpression) throws XPathExpressionException
//package com.java2s; import org.w3c.dom.*; import javax.xml.xpath.*; public class Main { public static Node xpathToNode(Document document, String xpathExpression) throws XPathExpressionException { XPath xpath = createXPath(); return (Node) xpath.evaluate(xpathExpression, document, XPathConstants.NODE); }/* w ww.j a v a 2 s .com*/ private static XPath createXPath() { return XPathFactory.newInstance().newXPath(); } }