Here you can find the source of xPathStr(String expr, Object context)
public static String xPathStr(String expr, Object context)
//package com.java2s; // modify it under the terms of the GNU General Public License import javax.xml.xpath.XPath; import javax.xml.xpath.XPathExpressionException; import javax.xml.xpath.XPathFactory; public class Main { private static ThreadLocal<XPath> XPATH_POOL = new ThreadLocal<XPath>() { @Override/*from ww w. jav a2 s . com*/ protected XPath initialValue() { return XPathFactory.newInstance().newXPath(); } }; /** * @return the string obtained from evaluating an XPath expression * @since 1.14.1 */ public static String xPathStr(String expr, Object context) { try { return xPath().evaluate(expr, context); } catch (XPathExpressionException e) { throw new IllegalArgumentException(expr, e); } } /** * @return an XPath object that can be used by the current thread * @since 1.14.1 */ public static XPath xPath() { return XPATH_POOL.get(); } }