aspose file tools*
The moose likes XML and Related Technologies and the fly likes SAX vs DOM  when to use them Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "SAX vs DOM  when to use them" Watch "SAX vs DOM  when to use them" New topic
Author

SAX vs DOM when to use them

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Hi,
i know sax is to used when we have a large file which takes a lot of memory and SAX is event based.
are there any other differences.
Regds.
Rahul
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
DOM was designed as a language-independent object model to hold any XML data, and as such is a large and complex system. It suits well the two-phase approach of first loading an XML document in, then performing various operations on it.
SAX, on the other hand, was designed as a fairly light-weight system using a single-phase approach. With SAX, user-specified operations are performed as the document is loaded. Some applications use SAX to generate a smaller object model, with uninteresting information filtered out, which is then processed similarly to DOM.
Note that although DOM and SAX are the well-known "standard" XML APIs, there are plenty of others available, and sometimes a particular application may be better off using a non-standard API. With XML the important bit is always the data; code can be rewritten.


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
Murali Mohan
Ranch Hand

Joined: Jun 14, 2001
Posts: 47
1)SAX is faster than DOM.
2)SAX is good for large documents because it takes comparitively less memory than Dom.
3)SAX takes less time to read a document where as Dom takes more time.
4)With SAX we can access data but we can't modify data.With Dom we can modify data.
5)We can stop the SAX parsing when ever and where ever you want.
6)SAX is sequential parsing but with DOM we can move to back also.
7)To parse machine generated code SAX is better.To parse human readable documents DOM is useful.

[This message has been edited by Murali Mohan (edited June 15, 2001).]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SAX vs DOM when to use them
 
Similar Threads
Difference Between DOM and SAX
When do you use sax and when to use DOM?
where can i get the api for sax parser??
XML
serial processing and cross searching