private Document parseStringToDOM ( String s , String encoding ) { try { DocumentBuilderFactory factory = DocumentBuilderFactory . newInstance ( ) ; factory . setValidating ( false ) ; InputStream is = new ByteArrayInputStream ( s . getBytes ( encoding ) ) ; Document doc = factory . newDocumentBuilder ( ) . parse ( is ) ; return doc ; } catch ( SAXException e ) { e . printStackTrace ( ) ; System . out . println ( "Exception processing string." ) ; } catch ( ParserConfigurationException e ) { e . printStackTrace ( ) ; System . out . println ( "Exception processing string." ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; System . out . println ( "Exception processing string." ) ; } return null ; }
Parse a string to a DOM document .