Xerces Serialization

The Apache XML Project's Xerces-J includes the org.apache.xml.serialize package for writing DOM Document objects onto output streams. Although this class is bundled with Xerces, it works with any DOM2 implementation. It does not depend on the details of the Xerces implementation classes, only on the standard DOM interfaces.

The basic technique for serializing documents with org.apache.xml.serialize is as follows:

1.
Configure an OutputFormat object with the serialization options you want.
2.
Connect an OutputStream to the location where you want to store the data.
3.
Use the OutputStream and the OutputFormat to construct a new XMLSerializer object.
4.
Pass the Document object you want to serialize to the XMLSerializer ...

Get Processing XML with Java™: A Guide to SAX, DOM, JDOM, JAXP, and TrAX now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.