Reasons to use DOM when creating an XML message

M

msaladin

Hi all,

I'd like to list some arguments for using DOM when creating an XML
message. For me, there is only one way to create complex XMLs, that is
using DOM.

There is of course another way to create an XML, and this is to iterate
through all the objects that needs to be serialized into the XML and
then use toXML()-methods in each object instance that should appear in
the XML. In Java, you could pass a StringBuffer which will then be
filled by the toXML()-method. I think this procedure is completey
correct for small XML snippets (e.g. two or three tags with some
attributes), but it's not good to use this approach for larger and more
complex XMLs. To create larger and more complex XMLs, I would use DOM.

But this is just my gut feeling, I need to have arguments to persuade
other people. Here is a list of my arguments, but currently, the list
is rather small.

1) Special characters are handled by DOM (e.g. "<", ">", "&" etc...)
2) Char-Encodings are handled by DOM
3) XML-Schema-Validation can be used and the resulting XML can be
validated before being written to disk
4) It's easier to change the XML layout in the future, because the
order in which you serialize the objects to XML does not matter with
DOM.

Any other arguments?
Thank for your help.

Michael
 
J

Joe Kesselman

I'd like to list some arguments for using DOM when creating an XML
message. For me, there is only one way to create complex XMLs, that is
using DOM.

Or "hand-constructed" SAX event streams. Or a data-binding tool.

The basic argument for any of these is "Using APIs simplifies the task
while helping to ensure that you don't overlook any of the necessary
details."

See the entry in http://www.w3.org/DOM/faq.html discussing some of the
tradeoffs between SAX and DOM.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top