Java tutorial
//package com.java2s; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import javax.xml.xpath.XPathConstants; import javax.xml.xpath.XPathExpression; import javax.xml.xpath.XPathExpressionException; public class Main { public static NodeList getNodeList(Node node, XPathExpression xpath) { try { Object result = xpath.evaluate(node, XPathConstants.NODESET); return (NodeList) result; } catch (XPathExpressionException e) { throw new RuntimeException("Invalid XPath", e); } } }