1. Serialize DOM


Serialize DOM


Q expansion. After creating a document using DOM how can I serialize it as an XML document.

Two ways

1) if your DOM is ofTXDocument class then you can use method printWithFormat(Writer w)(sorry I am not sure of the name but it is there) avaible in TXDocument

2) See the code in DOMWriter available in samples directory I think

By the way, there does not seem to be any formal way in DOM for

a) creating an empty DOM 
b) reading from an XML
c) writing out it as again as an XML

To which question Ingo Macherius wrote In the PDOM.domutil package all of those helper functions are contained.

Since DOM is "XML in memory" and XML is "serialized DOM" how come the relationship between the two is not defined at all.

SAX of course has a standard way to read parser.parse(InputSource in).