In What scenarios will you use a DOM parser and SAX parser

Q

In What scenarios will you use a DOM parser and SAX parser?

✍: Guest

A

If you do not need all the data from the XML file then SAX approach is much preferred than DOM as DOM can quiet memory intensive. In short if you need large portion of the XML document its better to have DOM.
With SAX parser you have to write more code than DOM.
If you want to write the XML in to a file DOM is the efficient way to do it.
Some time you only need to validate the XML structure and do not want to retrieve any Data for those instances SAX is the right approach.

2007-10-31, 5533👍, 0💬