Here you can find the source of getXPath(String expression)
public static XPathExpression getXPath(String expression)
//package com.java2s; import javax.xml.xpath.XPathExpression; import javax.xml.xpath.XPathExpressionException; import javax.xml.xpath.XPathFactory; public class Main { private static XPathFactory xpathFactory; public static XPathExpression getXPath(String expression) { try {/*from w ww . j av a 2s. c o m*/ return getXPathFactory().newXPath().compile(expression); } catch (XPathExpressionException e) { throw new RuntimeException("Invalid XPath Expression " + expression, e); } } /** * 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; } }