In Previous articles we have discussed about JAXP in detail.
- Introduction to DOM
- Introduction to JAXP
- Create XML File using DOM Parser of JAXP and Transformation APIs
- Traverse XML file using DOM Parser of JAXP
- Searching XML File using DOM Parser of JAXP
- Read XML File using SAX Parser in JAVA
- XML Tree Viewer using SAX Parser in JAVA with Jtree, JFileChooser component of Swing
To summarize all, lets discuss difference between both approach.
SAX Parser:
- Event based model.
- Serial access (flow of events).
- Low memory usage (only events are generated).
- To process parts of the document (catching relevant events).
- To process the document only once.
- Backward navigation is not possible as it sequentially processes the document.
- Objects are to be created.
DOM Parser:
- (Object based)Tree data structure.
- Random access (in-memory data structure).
- High memory usage (the document is loaded into memory).
- To edit the document (processing the in-memory data structure).
- To process multiple times (document loaded in memory).
- Ease of navigation.
- 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.
Leave a Reply