Here you can find the source of selectNodes(String xPath, Node target)
public static NodeList selectNodes(String xPath, Node target)
//package com.java2s; //License from project: Open Source License 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 { public static NodeList selectNodes(String xPath, Node target) { XPath xpathForUri = XPathFactory.newInstance().newXPath(); NodeList nodes = null;//from w w w .j a v a2 s . co m try { XPathExpression expr = xpathForUri.compile(xPath); nodes = (NodeList) expr .evaluate(target, XPathConstants.NODESET); } catch (XPathExpressionException e) { throw new RuntimeException(e); } return nodes; } }