java and xml

In the interest of promoting a little XML knowledge, I did a little poking into SAX and DOM. I found two useful links, which I recommend be perused in order:
1-A good short overview from developerlife.com
2-More detail in the form of a JDC Tech Tip

The overall gist seems to be that DOM will map an entire document, while SAX will run through it linerally. Both do the same thing (give one access to a xml formatted file), but their methods differentiate them. DOM gives you detail and access to the whole enchilada at the cost of overhead, while SAX gives you a speed bonus if your parsing requirements don’t get too complex.

An analogy: DOM is a pack-mule, while SAX is a speedy Golden Retriever. I would be amazed if that analogy fits, but I wanted to make it just the same.

This entry was posted in learning java. Bookmark the permalink.

2 Responses to java and xml

  1. bturnip says:

    I looked at some of the Turtle notes about SAX vs DOM and saw that it stated that “SAX is very useful for large documents”. It is my understanding from my quick overview of the links above that SAX is also useful for small documents, especially so if the requirements are simple.
    Interesting in that it seems that I am pretty sure that the DOM method is used more often of the two. Perhaps it has been around longer.

  2. tjm says:

    Off the top of my head my guess would be that since DOM “creates a tree of nodes” blah blah blah, it might have needless overhead for small documents, so maybe SAX is therefore the chosen method at both ends of the spectrum. Just a guess.

Leave a Reply

Your email address will not be published. Required fields are marked *