Java tutorial
//package com.java2s; import javax.xml.xpath.XPath; import javax.xml.xpath.XPathConstants; import javax.xml.xpath.XPathFactory; import org.w3c.dom.NodeList; public class Main { private static XPathFactory factory = XPathFactory.newInstance(); public static NodeList select(Object item, String xpathExpression) throws Exception { XPath xpath = factory.newXPath(); return (NodeList) xpath.evaluate(xpathExpression, item, XPathConstants.NODESET); } }