This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes Serialize XML with JAXP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Serialize XML with JAXP" Watch "Serialize XML with JAXP" New topic
Author

Serialize XML with JAXP

Ronald Francis
Ranch Hand

Joined: Aug 02, 2001
Posts: 30
I am modifying an XML file in memory. is there a standard way to write my changes out to file ?
Karthik Guru
Ranch Hand

Joined: Mar 06, 2001
Posts: 1209
Originally posted by Ronald Francis:
I am modifying an XML file in memory. is there a standard way to write my changes out to file ?

yes take a look @ the javax.xml.transform.Result interface and it's implementations in packages
javax.xml.transform.stream ( for ur case sicne you want to serialize),
javax.xml.transform.dom,
javax.xml.transform.sax,
But you w'd be required to do a transformation!
on the XML file that you have in memory.
Then use an identity stylesheet (ie invoke the no-argument newTransformer() method to obtain the TransformerFactory instance) and then do a transform() providing the appropriate implemenation of the Result interface.
You can use StreamResult for your case.
I guess that's the only way you can serialize a in-meomory xml to a file using "JAXP".
Ofcourse parsers provide better ways of serializing the in-memory representation of XML file which in turn are not portable across parsers.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Serialize XML with JAXP
 
Similar Threads
Convert XSD to XML
Content is not allowed in prolog (EDIT: emergency code fix help!)
XSD
How to do XML to DB using Message Driven Bean?
Annotation in spring