Here you can find the source of getNodes(Node node, String expStr)
private static List<Node> getNodes(Node node, String expStr) throws XPathExpressionException
//package com.java2s; /**//from w ww.j a v a2 s . c om * Copyright 5AM Solutions Inc * Copyright SemanticBits LLC * Copyright AgileX Technologies, Inc * Copyright Ekagra Software Technologies Ltd * * Distributed under the OSI-approved BSD 3-Clause License. * See http://ncip.github.com/cacis/LICENSE.txt for details. */ import java.util.ArrayList; import java.util.List; 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 List<Node> getNodes(Node node, String expStr) throws XPathExpressionException { final List<Node> nodes = new ArrayList<Node>(); final XPathFactory fac = XPathFactory.newInstance(); final XPath xpath = fac.newXPath(); final XPathExpression exp = xpath.compile(expStr); final NodeList nl = (NodeList) exp.evaluate(node, XPathConstants.NODESET); for (int i = 0; i < nl.getLength(); i++) { nodes.add(nl.item(i)); } return nodes; } }