SAX:
1. Parses the document on node by node basis.
2. Does not store the XML in memory.
3. We can not insert or delete a node.
4. This model uses top to bottom traversing.
5. This model does not preserve comments.
6. It runs little faster than DOM
DOM
1. Stores the entire XML document into memory before processing
2. Occupies more memory
3. We can insert or delete nodes
4. This model can traverse in any direction.
5. This model preserves comments.
6. It runs slower than SAX model
So, when to choose what model to use?
Here is what you can do.
If you just need to read a node, but do not require to insert/delte node, then use SAX.
If you require node manipulation(insert/delete) nodes, use DOM.
No comments:
Post a Comment