Java tutorial
//package com.java2s; //License from project: Open Source License import org.w3c.dom.NodeList; import org.xml.sax.InputSource; import javax.xml.xpath.XPath; import javax.xml.xpath.XPathConstants; import javax.xml.xpath.XPathExpressionException; import java.io.StringReader; public class Main { public static NodeList extractNodeList(XPath xpath, String nodePath, String xmlString) { InputSource inputSource = new InputSource(new StringReader(xmlString)); try { return (NodeList) xpath.evaluate(nodePath, inputSource, XPathConstants.NODESET); } catch (XPathExpressionException e) { return null; } } }