Here you can find the source of getXPath()
public static synchronized XPath getXPath()
//package com.java2s; import javax.xml.xpath.XPath; import javax.xml.xpath.XPathFactory; public class Main { /** Reusable XPath factory. */ private static XPathFactory xpathFactory; /** Reusable XPath. */ private static XPath xpath; /**/* w ww . jav a2 s . co m*/ * Gets the XPath API, creating it if necessary. * * @return the XPath API. */ public static synchronized XPath getXPath() { if (xpath == null) { xpath = getXPathFactory().newXPath(); } return xpath; } /** * Gets the XPath factory, creating it if necessary. * * @return the XPath factory. */ public static synchronized XPathFactory getXPathFactory() { if (xpathFactory == null) { xpathFactory = XPathFactory.newInstance(); } return xpathFactory; } }