Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DOM and SAX

 
Hari babu
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
Which parser is more applicable in a scenario where high performance and less memory is the key ? Can any one tell me how to decide in this case ?
thanks in advance
Hari
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may want to have a look at the following link:
Java Web Services Tutorial: An Overview of the Packages which enumerates the main differences between SAX and DOM (very briefly) and also gives hints on when to use either one.
 
Hari babu
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Usually the thumb rule is when you want high performance you use DOM, but when you want less memory to use, you go for SAX. But i saw some mock exams giving the above 2 constraints, so i was confused in choosing, can some one help me
Hari
 
Ajith Kallambella
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree with using DOM for efficient memory use. However, DOM for high performance can be disputed. Infact, DOM performance tends to slow down with the increase in the size of the document. However it is implemented, traversing a DOM tree essentially means chasing down the pointers.
I am a great advocate of using SAX for performance, not DOM. The problem with SAX is the programming model is not very clean. If you lose an event, you have to start all over again.
Notwithstanding the confusion here( between the use of DOM vs. SAX in a performance critical scenario ), I suggest that you read the question(s) carefully and take into account all the prevailing conditions and facts stated in the question.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic