• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

differences between DOM and SAX parser?

 
Sudhakar Reddy Kurakula
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please give me answer.
 
Kaise a.Zakkar
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well Dear Sudhakar
the main deffenence between those two techniques in parsing XML documents are
the following:
1- if you are working on some critical performance issues like time and storage , you should go for the SAX,but why...
well , SAX Api depends on what i used to call afly parser, so the xml document you are going to parse did not loaded completely to the memory ,SAX parser garantee that the document is parsed step by step ,only one element at a time
is treated .and so on till there is no more elements in the documnet,and this
technique is so valuable if you are comunicating with some server configuration xml files ,and you need urgent event driven actions,not to drop all the document into your memory and begin parsing.
2-what Really DOM doing is that it forms what's called a Tree of Nodes to the whole parts of the xml documnet when it begin parsing , so you will add this tree to your memory and them DOM begins his work .
so that's it
 
Prabhu Venkatachalam
Ranch Hand
Posts: 502
Java jQuery Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
SAX and DOM were both designed to allow programmers to access their information in XML without having to write a parser.

DOM Parser - use this when XML file size is small. Because of, it loads full XML in Tree Structure.

Advatage: You can iterate in both ways(back and forth). But SAX is event based model and iteration happens only in one way(forward).

Disadvatage: MEMORY CONSUMPTION IS MORE. In case of SAX it is less.

SAX parser- use this when XML size is huge.

Please have a look at this URL which gives in more detail about when to use SAX? and when to use DOM?

hth,
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic