• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

xml doc to xml string using jaxp

 
slagy maggie
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an xml document,using JAXP.....how do i convert
this document back into an XML string,.....i know i can do this with using TXDocument(IBM PARSER),but that is not what my company is using....SO I NEED TO DO THIS USING JAXP........
please help!!!
 
Ajith Kallambella
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are you parsing the document? If you're using an InputSource( ie., org.xml.sax.InputSource), you could use InputSource.getByteStream() to get an instance of java.io.InputStream. You can also use InputSource.getCharacterStream() to get an instance of java.io.Reader corresponding to the XML source(file).
Once you have a handle to a i/o stream you can simply read the characters in the XML document into a string.

Hope that helps,
------------------
Ajith Kallambella M.
Sun Certified Programmer for the Java�2 Platform.
IBM Certified Developer - XML and Related Technologies, V1.
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Oreilly's Book Java Examples in a Nutshell which is listed in our Bunkhouse They have a example called XMLDocumentWriter.java it's in chapter 19 which is on-line It strictly used the org.w3c.dom package so it will work with any parser derived from it.
Licensing information for commercial use is Here
------------------
Hope This Helps
Carl Trusiak
 
slagy maggie
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks ajith
actually i achieved it by using XMLDocument found in crimson.jar
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic