- From: Joseph Kesselman <keshlam@us.ibm.com>
- Date: Mon, 7 May 2001 17:34:59 -0400
- To: "'www-dom@w3.org'" <www-dom@w3.org>
> I have an XML file which I read into a DOM and then I do some >transformations. How do I write it back to xml? This isn't standardized yet, though DOM Level 3 is working on a proposal for a Load/Save API which would address this (for those DOMs which implement it). For now, the answer is that you need to find or write code which reads the data out of the DOM and writes it out as XML syntax. Most XML parsers come with at least a basic version of this -- check the documentation for your preferred parser package, and/or its sample programs. In the Apache Xerces-J parser, to take one example, there is a package of "serialization" classes that provide this function. Since it adheres pretty strictly to the standard DOM and SAX APIs, you could use that code with most other Java DOMs, and since it's open souce you could port it to other languages. (In fact, if you port it to C++ and donate the result back to Apache you're likely to get a standing ovation; Xerces-C users have been eagerly waiting for someone to find time to tackle that project, and have been using the primitive-but-almost-adequate-for-most-purposes DOMPrint sample program as a stopgap solution.) ______________________________________ Joe Kesselman / IBM Research
Received on Monday, 7 May 2001 17:35:50 UTC