Here you can find the source of selectNodeList(Node contextNode, String expression)
public static NodeList selectNodeList(Node contextNode, String expression) throws XPathExpressionException
//package com.java2s; //License from project: LGPL import javax.xml.xpath.XPath; import javax.xml.xpath.XPathConstants; import javax.xml.xpath.XPathExpression; import javax.xml.xpath.XPathExpressionException; import javax.xml.xpath.XPathFactory; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { private static XPathFactory xpathFactory; public static NodeList selectNodeList(Node contextNode, String expression) throws XPathExpressionException { XPath xpath = getXPathFactory().newXPath(); XPathExpression xexpr = xpath.compile(expression); return (NodeList) xexpr.evaluate(contextNode, XPathConstants.NODESET); }//from w ww .j a va 2 s .c o m public static XPathFactory getXPathFactory() { if (xpathFactory == null) { xpathFactory = XPathFactory.newInstance(); } return xpathFactory; } }