String to XMLDocument. I have an xml document stored in a String variable. How do I take the String and parse it into an XMLDocument?

Roseanne Zhang

Q. How to parse an XML String?
A: Easy! No matter you using DOM (javax.xml.parsers.DocumentBuilder) or SAX (org.xml.sax.XMLReader), or vendor specific SAXParser/DOMParser, you all can use the same signature method parse(InputSource input) to parse you XML. Now the question becomes how to use String to make an InputSource.

  • Contruct a StringReader by using your XML String.
  • Contruct an InputSource by using your StringReader
  • Parse the InputSource by using parse(InputSource input)
Read javadoc for jaxp
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact