Here you can find the source of parseXPath(String expression, NamespaceContext nsContext)
public static XPathExpression parseXPath(String expression, NamespaceContext nsContext) throws XPathExpressionException
//package com.java2s; /*/* w ww.jav a2 s .c o m*/ * This file is part of experimaestro. * Copyright (c) 2014 B. Piwowarski <benjamin@bpiwowar.net> * * experimaestro is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * experimaestro is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with experimaestro. If not, see <http://www.gnu.org/licenses/>. */ import javax.xml.namespace.NamespaceContext; import javax.xml.xpath.XPath; import javax.xml.xpath.XPathExpression; import javax.xml.xpath.XPathExpressionException; import javax.xml.xpath.XPathFactory; public class Main { final static private XPathFactory XPATH_FACTORY = XPathFactory.newInstance(); public static XPathExpression parseXPath(String path) throws XPathExpressionException { return XPATH_FACTORY.newXPath().compile(path); } public static XPathExpression parseXPath(String expression, NamespaceContext nsContext) throws XPathExpressionException { XPath xpath = XPATH_FACTORY.newXPath(); xpath.setNamespaceContext(nsContext); return xpath.compile(expression); } }