Two Laptop Bag*
The moose likes Web Services and the fly likes When will we use DOM and SAX? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Web Services
Bookmark "When will we use DOM and SAX?" Watch "When will we use DOM and SAX?" New topic
Author

When will we use DOM and SAX?

ssiva kumar
Greenhorn

Joined: May 29, 2006
Posts: 9
Hi,
What are the differents between DOM and SAX...

DOM-->Tree Structure Data Dealing(What is meaning for tree)
SAX-->Event Data Dealing..(What is event)

But i have doubt for all xml is a tree structur view why we use sax some time and dom also some... plz explain when will we use sax and dom....
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42061
    
  64
DOM builds the complete XML tree in memory, which takes time and uses up a bunch of memory.

SAX, on the other hand, does not build any in-memory stuctures, and allows the developer to do something just with those nodes that the application is interested.

You'd use SAX if you don't need the XML tree (say, for later modification and saving), and want to save resources (time, memory). Drawback is (obviously) that you don't have the XML tree, so you can't easily determine, e.g., the parent or sibling of a given node.


Ping & DNS - my free Android networking tools app
 
GeeCON Prague 2014
 
subject: When will we use DOM and SAX?