Search

Saturday, April 24, 2010

What is the difference between SAX and DOM parser

 The main differences are as following :

SAX:
1. Parses node by node (Event based).
2. Doesnt store the XML in memory.
3. We can't insert or delete a node.
4. Top to bottom traversing.

DOM

1. Stores the entire XML document into memory before processing
2. Occupies more memory.
3. We can insert or delete nodes.
4. Traverse in any direction.

For large documents SAX is better choice  rather than DOM as it does not consume memory of JVM.

No comments:

Post a Comment