Reasons to use DOM when creating an XML message

Discussion in 'XML' started by msaladin@gmx.net, Jun 13, 2006.

  1. Guest

    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
    , Jun 13, 2006
    #1
    1. Advertising

  2. wrote:
    > 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.
    Joe Kesselman, Jun 13, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chris Berg
    Replies:
    8
    Views:
    2,139
    Roland
    Aug 21, 2005
  2. Desser
    Replies:
    7
    Views:
    608
    richard
    Aug 12, 2008
  3. Mark Volkmann

    reasons to use else inside rescue

    Mark Volkmann, Feb 7, 2006, in forum: Ruby
    Replies:
    5
    Views:
    100
    Mark Volkmann
    Feb 7, 2006
  4. Steve Midgley

    Reasons to use a buffer in IO::read?

    Steve Midgley, Dec 6, 2007, in forum: Ruby
    Replies:
    8
    Views:
    172
    Robert Klemme
    Dec 7, 2007
  5. Neil Gould
    Replies:
    0
    Views:
    436
    Neil Gould
    May 26, 2012
Loading...

Share This Page