Difference between SAX and DOM?

This question is related to Oracle Interview

Showing Answers 1 - 4 of 4 Answers

pravash

  • Jun 8th, 2005
 

SAX uses an event callback mechanism requiring you to code methods to handle events thrown by the parser as it encounters different entities within the XML document. 
DOM parses an XML document and returns an instance of org.w3c.dom.Document. This document object's tree must then be "walked" in order to process the different elements. 
 

  Was this answer useful?  Yes

shashidhar Mahavadi

  • Jun 8th, 2005
 

SAX parser requires to implement an event handler 
DOM object is an object in memory representing the parsed xml file and DOM object is actualy built up using SAX 



Your valueable suggessions are welcome

  Was this answer useful?  Yes

swamy reddy

  • Jul 16th, 2005
 

sax parser is used for only java-xml programms only. 
dom parser is for any lanaguage that is associated with xml concepts.

Habeeb Mohmed

  • Dec 15th, 2005
 

SAX Historical Background

! Simple API for XML

! Started as community-driven project

  "xml-dev mailing list

! Originally designed as Java API

  "Others (C++, Python, Perl) are now

supported

! SAX 2

  "Namespaces

 

SAX Features

! Event-driven

  "You provide event handlers

! Fast and lightweight

  "Document does not have to be entirely in memory

! Sequential read access only

! One-time access

! Does not support modification of document

 

 

Historical Background

l DOM is a standard defined by the

W3C, just like XML

l DOM was not designed specifically for

Java technology (unlike SAX)

l DOM is cross-platform and crosslanguage

uUses OMG?s IDL to define interfaces

uIDL to language binding

 

DOM Characteristics

l Access XML document as a

tree structure

l Composed of mostly element nodes

and text nodes

l Can ?walk? the tree back and forth

l Larger memory requirements

uFairly heavyweight to load and store

l Use it when for walking and modifying

the tree

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions