Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

learning about SAX Parser and the DOM Parsers

 
Isaac Ferguson
Ranch Hand
Posts: 841
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I am learning SAX Parser and the DOM Parser, so I have some questions

Could somebody help me a little bit please?

what's the difference between the SAX Parser and the DOM Parsers when processing XML files? What are the advantages and disadvantages of both? When would you use one over the other and vice versa?

Thanks

 
Vijaya Raghava
Ranch Hand
Posts: 37
Java Spring Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Use SAX when:
You need to scan large XML documents including: Scan huge files with little overhead.
You need more control over the parsing process: SAX does not actually do much only your program decides how anything is used, if at all.
You have limited system resources: SAX does not create many objects.
You need high performance: SAX quickly locates elements within any size XML document.


Use DOM when:
You need to make multiple processing passes over an XML document and no need to rescan the document on each pass
You need to merge several XML documents together. Here the structures can be the same or different
You need to do a lot with document content including: Sharing content with other processes, Frequent access of content
You need to modify document…including Content or Structure or Order
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic