Difference between SAX and DOM parsers? December 28, 2006
Posted by Allu in JAVA.trackback
SAX Parser:
· A SAX (Simple API for XML) parser does not create any internal structure. Instead, it takes the occurrences of components of an input document as events, and tells the client what it reads as it reads through the input document.
· A SAX parser serves the client application always only with pieces of the document at any given time.
· A SAX parser, however, is much more space efficient in case of a big input document (because it creates no internal structure). What’s more, it runs faster and is easier to learn than DOM parser because its API is really simple. But from the functionality point of view, it provides a fewer functions, which means that the users themselves have to take care of more, such as creating their own data structures.
DOM Parser:
· A DOM (Document Object Model) parser creates a tree structure in memory from an input document and then waits for requests from client.
· A DOM parser always serves the client application with the entire document no matter how much is actually needed by the client.
· A DOM parser is rich in functionality. It creates a DOM tree in memory and allows you to access any part of the document repeatedly and allows you to modify the DOM tree. But it is space inefficient when the document is huge, and it takes a little bit longer to learn how to work with it.
hi sir,
whatever u giving the suggestions to my questions. its very nice.
thanks to u.
with regards,
prasad.
I agree, great stuff. By the here are few more differences between DOM and SAX parser in Java.
It is really good explanation.
sir, can i know what is the exact difference between API and PARSER?
Hello sir
What u giving ,it very good.
hello sir,
thank u very much for giving valuable information on parsers
Thank you very much for your explanation.
Pls some one clarify client request in above detail.
You may also want to look at vtd-xml, the latest and most advanced XML processing
API
vtd-xml
For reading of large xml file, which one is good sir(either DOM or SAX).
SAX for large files should be an obvious choice, unless you have a very bing chunk of memory with you.
thank u…..
its really very helpful.
thank u sir
sir please give examples about that above topic
it is very helpful to the others and it can be clarified
thanku
thk u
its really useful for the interview point of view
than you very short and good explanation
thanks…. it gives a proper idea about both… 🙂
very good
good one
goof one
tanx for the post
super
thx u dis is literally gud nd more helpful 4 me
gud one
Quite a good explainantion 🙂
Hai sir,
This is very usefull for me.
nice explaination
very use ful information sir :-)very very thank ful to you.:)sir , could you please tell me how to use there parsing techniques in android ?where to place them android tree structure ?
this is realy a very clear explanation of difference between sax and dom parser… thankyou
It is very clear explaination
Is any one tell me plz that sax parser and Expart parser both are same or differnet and how?
Have you tired Expresso XML Parser? It’s a high performance parser that has a graphical interface. You log onto a website and parse your XML file online so you can create parsing rules without writing code. Then you link up to your existing project using their client code. At the moment they have client code in java and javascript. They have a free developer version at http://www.sxml.com.au
Thanks for valuable information sir
Thank you so much for this straight forward comparison.
really nice explanation
[…] Here you are reading the data, hence you should be using SAX parser only. DOM is generally used to read/ write XML file. See the diff. over here. […]
great stuff
simply gud
How do i convert an xml file to html?
Se você gosta de jogar jogos de tabuleiro ou pôquer, jogue aqui!