Difference between SAX and DOM Parsers

In Previous articles we have discussed about JAXP in detail.

To summarize all, lets discuss difference between both approach.

SAX Parser:

  1. Event based model.
  2. Serial access (flow of events).
  3. Low memory usage (only events are generated).
  4. To process parts of the document (catching relevant events).
  5. To process the document only once.
  6. Backward navigation is not possible as it sequentially processes the document.
  7. Objects are to be created.

DOM Parser:

  1. (Object based)Tree data structure.
  2. Random access (in-memory data structure).
  3. High memory usage (the document is loaded into memory).
  4. To edit the document (processing the in-memory data structure).
  5. To process multiple times (document loaded in memory).
  6. Ease of navigation.
  7. Stored as objects.

For simpler applications, that complexity may well be unnecessary. For faster development and simpler applications, one of the object-oriented XML-programming standards, such as JDOM ( http://www.jdom.org) and DOM4J ( http://dom4j.org/), might make more sense.

Posted

in

by

Tags:


Related Posts

Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from Jitendra Zaa

Subscribe now to keep reading and get access to the full archive.

Continue Reading