public static NodeList getNodeList ( final String xml , final String xpathExpression ) throws XPathExpressionException , ParserConfigurationException , SAXException , IOException { final DocumentBuilderFactory domFactory = DocumentBuilderFactory . newInstance ( ) ; domFactory . setNamespaceAware ( true ) ; final DocumentBuilder builder = domFactory . newDocumentBuilder ( ) ; final Document doc = builder . parse ( xml ) ; final XPath xpath = XPathFactory . newInstance ( ) . newXPath ( ) ; final XPathExpression expr = xpath . compile ( xpathExpression ) ; final Object result = expr . evaluate ( doc , XPathConstants . NODESET ) ; final NodeList nodes = ( NodeList ) result ; return nodes ; }
Gets the node list from the given xml file and the given xpath expression .