• 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

SAX or DOM??

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Everyone

I am currently busy with a Web Application using servlets and XML. The XML files I use will mainly be machine generated code. I am using my XML files mainly as a means of user profiling.

After reading many websites that claim DOM as the way to go with parsers and just as many which claim SAX as the only way to go, I am confused.


Which of these two parsers is the best one,? What are the main differences?, and Which parser is supported best in the JAVA API?

Any help and advice will be appreciated.
 
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which is best depends on what you're trying to do. As for what the differences are, I'll let you go out and do a little research. Both parser types are well supported by the Java API.
 
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
An analogy might be fishing on a bridge in a running river, where the river is the XML:

For SAX, the fisherman is going to stand on the bridge and has decided that she/he is only going to catch salmon, i.e. let all other species of fish go on by. So, for this fisherman, the SAX parser catches only the "salmon" elements as they go by.

For DOM, the fisherman is going to run a giant net across the river, and catch every fish in the river.

That's why it's sometimes said DOM is "heavier" than SAX. :-)

Might be a somewhat silly analogy, but helps me remember the difference.

Ben
 
Nathaniel Stoddard
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Poor salmon.
 
reply
    Bookmark Topic Watch Topic
  • New Topic