File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Serialize XML with JAXP" Watch "Serialize XML with JAXP" New topic

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 ( for ur case sicne you want to serialize),
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:
subject: Serialize XML with JAXP
Similar Threads
How to do XML to DB using Message Driven Bean?
Convert XSD to XML
Annotation in spring
Content is not allowed in prolog (EDIT: emergency code fix help!)