Here you can find the source of selectNodes(final Node node, final String xPath)
public static List<Node> selectNodes(final Node node, final String xPath) throws XPathExpressionException
//package com.java2s; //License from project: Apache License import java.util.AbstractList; import java.util.List; import javax.xml.xpath.XPathConstants; 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 _xpf = XPathFactory.newInstance(); public static List<Node> selectNodes(final Node node, final String xPath) throws XPathExpressionException { return wrapNodeList((NodeList) _xpf.newXPath().evaluate(xPath, node, XPathConstants.NODE)); }/*from ww w .j a va2 s . co m*/ public static List<Node> wrapNodeList(final NodeList nodeList) { return new AbstractList<Node>() { @Override public Node get(final int index) { return nodeList.item(index); } @Override public int size() { return nodeList.getLength(); } }; } }