Java tutorial
//package com.java2s; import org.w3c.dom.*; import javax.xml.xpath.*; public class Main { public static Document doc = null; private static NodeList getNodeListByXpath(String xpath) throws Exception { XPath xPath = XPathFactory.newInstance().newXPath(); String expression = xpath; NodeList nodeList = (NodeList) xPath.compile(expression).evaluate(doc, XPathConstants.NODESET); return nodeList; } }