private NodeList getNodeList ( final String xmlString , final String tagName ) throws ParserConfigurationException , SAXException , IOException { DocumentBuilderFactory dbf = DocumentBuilderFactory . newInstance ( ) ; dbf . setValidating ( false ) ; dbf . setFeature ( "http://xml.org/sax/features/namespaces" , false ) ; dbf . setFeature ( "http://xml.org/sax/features/validation" , false ) ; dbf . setFeature ( "http://apache.org/xml/features/nonvalidating/load-dtd-grammar" , false ) ; dbf . setFeature ( "http://apache.org/xml/features/nonvalidating/load-external-dtd" , false ) ; DocumentBuilder db = dbf . newDocumentBuilder ( ) ; InputSource is = new InputSource ( ) ; is . setCharacterStream ( new StringReader ( xmlString ) ) ; Document doc = db . parse ( is ) ; LOG . info ( "Getting tagName: " + tagName ) ; NodeList nodes = doc . getElementsByTagName ( tagName ) ; return nodes ; }
Gets the nodes list for a given tag name .