Here you can find the source of evalXPath(String path, Document doc)
public static String evalXPath(String path, Document doc)
//package com.java2s; //License from project: Open Source License import org.w3c.dom.Document; import javax.xml.xpath.XPath; import javax.xml.xpath.XPathExpressionException; import javax.xml.xpath.XPathFactory; public class Main { public static String evalXPath(String path, Document doc) { XPath xpath = newXPath(); try {/*from w ww. j av a2s .c om*/ return xpath.evaluate(path, doc); } catch (XPathExpressionException e) { throw new RuntimeException(e); } } public static XPath newXPath() { XPathFactory factory = XPathFactory.newInstance(); XPath xpath = factory.newXPath(); return xpath; } }