Re: String output of XML documents

keshlam@us.ibm.com wrote:
> 
> > I supposed I could find in this interface a method  enabling to format
> the
> > XML tree content to a string value.
> 
> Sorry, but this is not yet standardized in the DOM APIs. DOM Level 3 is
> planning to include a chapter on serialization and deserialization of DOMs,
> which will address this.
> 
> Meanwhile, there are off-the-shelf implementations of this operation which
> you could "steal" for use in your own program. 

Even open source versions (no theft possible :-) that show some of the
advantages of not having this be part of DOM at all:

    http://home.pacbell.net/david-b/xml/

There are two packages there ... the "DOM2" package implements the CR
(including events and other extension modules), but the printing support
is in the "utilities" package and is not DOM-specific.  The "domparse"
example shows a complete round-tripping scenario:  it reads a document
into your specified DOM, and then writes it out.  Converting to strings
is easy using the java.io classes for that purpose (that is, StringReader
and StringWriter).

By the way, those packages may be very useful also to understand how
the latest versions of SAX and DOM support namespaces and suchlike,
and how SAX2beta works.

- Dave

Received on Tuesday, 8 February 2000 17:24:17 UTC