public static Document stringToDOM ( String xmlString , boolean namespaceAware ) { try { InputSource in = new InputSource ( ) ; in . setCharacterStream ( new StringReader ( xmlString ) ) ; DocumentBuilderFactory dbFact = DocumentBuilderFactory . newInstance ( ) ; dbFact . setNamespaceAware ( namespaceAware ) ; return dbFact . newDocumentBuilder ( ) . parse ( in ) ; } catch ( IOException e ) { log . warn ( "I/O error when parsing XML :" + e . getMessage ( ) + "\n" + xmlString , e ) ; } catch ( SAXException e ) { log . warn ( "Parse error when parsing XML :" + e . getMessage ( ) + "\n" + xmlString , e ) ; } catch ( ParserConfigurationException e ) { log . warn ( "Parser configuration error when parsing XML :" + e . getMessage ( ) + "\n" + xmlString , e ) ; } return null ; }
Parses an XML document from a String to a DOM .