Java tutorial
//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.XPathFactory; import org.w3c.dom.*; public class Main { public static NodeList selectNodeList(Node xml, String xPath) throws Exception { XPath xpath = XPathFactory.newInstance().newXPath(); XPathExpression expr = xpath.compile(xPath); NodeList nodeList = (NodeList) expr.evaluate(xml, XPathConstants.NODESET); return nodeList; } }