Wednesday, February 18, 2009

Diffrence SAX between DOM

Both SAX and DOM are used to parse the XML document. Both has advantages and disadvantages and can be used in our programming depending on the situation.
SAX parser.................................
1.
Parses node by node.
2.
Doesn’t store the XML in memory.
3.
We cant insert or delete a node.
4.
Top to bottom traversing.
5.
SAX is an event based parser
6.
SAX is a Simple API for XML.
7.Import class

import javax.xml.parsers.*;
import org.xml.sax.*;
import org.xml.sax.helpers.*;

8.
doesn’t preserve comments
9.
SAX generally runs a little faster than DOM.


whereAS...............................................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.
5.
DOM is a tree model parser.
6.
Document Object Model (DOM) API.
7.Import class
import javax.xml.parsers.*;
import org.w3c.dom.*;

8.preserves comments
9.
SAX generally runs a little faster than DOM.

No comments: