Here you can find the source of getXpath()
public static XPath getXpath()
//package com.java2s; //License from project: Apache License import javax.xml.xpath.XPath; import javax.xml.xpath.XPathFactory; public class Main { private static final ThreadLocal<XPath> xpathTL = new ThreadLocal<XPath>(); public static XPath getXpath() { try {/* www .j a v a 2s . c o m*/ XPath xpath = xpathTL.get(); if (xpath == null) { xpath = XPathFactory.newInstance().newXPath(); xpathTL.set(xpath); } return xpath; } catch (Exception e) { throw new RuntimeException(e); } } }