OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help



   Re: [xml-dev] Xerces, XML Parsers and support for creating Documents.

[ Lists Home | Date Index | Thread Index ]

Murali Mani wrote:
> xerces 2.0.1 -- there is an XML serializer with which we can do it.

Both Xerces2 (latest 2.0.1) and Xerces1 (last version 1.4.4) support
serialization of documents.
> This is a functionality which I require almost regularly, and I almost
> always find difficult to find. Also none of the examples provided also
> talk about this. I would like to ask why this is so??

Well, it is an open source project and we don't have that much people
volunteering to write documentation (or contribute code)..

There are two ways to serialize your DOM document. 

[1] Serialize (or load) a document using DOM Level 3.
In the latest release (2.0.1) we support DOM Level 3 Load/Save Working
Draft. The support is experimental (means that interfaces might change)
and not complete (we don't support filters yet). We do provide
implementation for DOMBuilder and DOMWriter -- and I believe this is the
functionality you are looking for.

For more information visit:

[2] Serialize document using XMLSerializer, as in your example.
>  DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance ();
>   docBuilder = factory.newDocumentBuilder ();
>   Document doc = docBuilder.newDocument ();
>   Element el = doc.createElement ("root");
>   doc.appendChild (el);

The above is correct.
Here is an example for XMLSerializer:
OutputFormat format = new OutputFormat((Document)core);
// set format
// serialize
XMLSerializer toFile = new XMLSerializer (new FileWriter("output.xml"),

In the future, please post your questions about Xerces to

Elena Litani / IBM Toronto


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS