Here you can find the source of xPath()
public static XPath xPath()
//package com.java2s; // modify it under the terms of the GNU General Public License import javax.xml.xpath.XPath; import javax.xml.xpath.XPathFactory; public class Main { private static ThreadLocal<XPath> XPATH_POOL = new ThreadLocal<XPath>() { @Override/*from w w w. ja v a 2 s .c om*/ protected XPath initialValue() { return XPathFactory.newInstance().newXPath(); } }; /** * @return an XPath object that can be used by the current thread * @since 1.14.1 */ public static XPath xPath() { return XPATH_POOL.get(); } }