• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

differences between DOM and SAX parser?

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please give me answer.
 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 502
jQuery Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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,
 
Mo-om! You're embarassing me! Can you just read a tiny ad like a normal person?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic