This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes xml doc to xml string using jaxp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "xml doc to xml string using jaxp" Watch "xml doc to xml string using jaxp" New topic
Author

xml doc to xml string using jaxp

slagy maggie
Ranch Hand

Joined: Feb 20, 2001
Posts: 35
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

Joined: Mar 17, 2000
Posts: 5782
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.


Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
Carl Trusiak
Sheriff

Joined: Jun 13, 2000
Posts: 3340
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


I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
slagy maggie
Ranch Hand

Joined: Feb 20, 2001
Posts: 35
thanks ajith
actually i achieved it by using XMLDocument found in crimson.jar
 
Don't get me started about those stupid light bulbs.
 
subject: xml doc to xml string using jaxp