Main Page

Previous Section Next Section

When to Use DOM

The difference between SAX and DOM is the difference between sequential, read-only access and random, read-write access (an analogy is SAX parsing XML on the time axis and DOM parsing on the space axis). If, during processing, there is a need to move laterally between sibling elements or nested elements or to back up to a previous element processed, DOM is probably a better choice.

However, creating and manipulating DOMs is memory-intensive, and this makes DOM processing a bad choice if the XML is large and complicated or the JVM is memory-constrained, as in J2ME devices.

Previous Section Next Section

JavaScript Editor Java Tutorials Free JavaScript Editor