what is the difference between SAX Parser and DOM Parser??

Answers were Sorted based on User's Feedback



what is the difference between SAX Parser and DOM Parser??..

Answer / penchala

Both SAX and DOM are used to parse the XML document. Both
has advantages and disadvantages and can be used in our
programming depending on the situation
SAX:
1. Parses node by node
2. Doesnt store the XML in memory
3. We cant insert or delete a node
4. Top to bottom traversing
DOM
1. Stores the entire XML document into memory before processing
2. Occupies more memory
3. We can insert or delete nodes
4. Traverse in any direction.
If we need to find a node and doesnt need to insert or
delete we can go with SAX itself otherwise DOM provided we
have more memory.

Is This Answer Correct ?    197 Yes 11 No

what is the difference between SAX Parser and DOM Parser??..

Answer / guest

1. sax is an event based parser and raise and event, while
dom is not
2. sax is forward only where as dom can acess both was
forward as well as backwards.
3. sax parses the file as it reads where as the dom loads
the file into memory to parse the file.
4. Sax does not have memory constraints where as the dom
has momory constraints as xml file is loaded into the
momory to parse the file.
5. sax is read only , dom is read and write both.
6. if you have to parse and use the content only once ,
consider using sax if the xml file and content are used
extensively then consider using dom

Is This Answer Correct ?    187 Yes 12 No

what is the difference between SAX Parser and DOM Parser??..

Answer / chaithanya

hii Penchala..

U r Explination is pretty good..

Is This Answer Correct ?    48 Yes 14 No

what is the difference between SAX Parser and DOM Parser??..

Answer / shyam miyatra

It really nice Explanation by penchala the more about XML

SAX :
---
SAX Parser is the one which is developed to run the java
programs especially.

DOM:
---
DOM is developed by w3c consortium so that it is an open
standard.
In DOM the xml file is arranged as a tree and backward and
forward search is possible for searching the tags and
evaluating the data which it holds.
It depends upon the application and ease of data
accessiblity.
If we want to extract the data from a xml file once we
have to move to SAX which is one time top to bottom read
approach and if we want ot randomly pick the data in an xml
file then the tree reperesentation of DOM model is to be
put into use. Thats all !

Is This Answer Correct ?    35 Yes 8 No

what is the difference between SAX Parser and DOM Parser??..

Answer / venkateswarlu

very nice explaination

Is This Answer Correct ?    29 Yes 12 No

what is the difference between SAX Parser and DOM Parser??..

Answer / simi

Cant we insert or delete a node in SAX????

Is This Answer Correct ?    49 Yes 35 No

what is the difference between SAX Parser and DOM Parser??..

Answer / ashish

DOM
1. Tree of nodes
2. Memory: Occupies more memory, preffered for small XML
documents
3. Slower at runtime
4. Stored as objects
5. Programmatically easy
6. Ease of navigation
SAX
1. Sequence of events
2. Doesn't use any memory preferred for large documents
3. Faster at runtime
4. Objects are to be created
5. Need to write code for creating objects
6. Backward navigation is not possible as it sequentially
processes the document

Is This Answer Correct ?    19 Yes 5 No

what is the difference between SAX Parser and DOM Parser??..

Answer / madhu

very good explanation

Thank you.

Is This Answer Correct ?    13 Yes 5 No

what is the difference between SAX Parser and DOM Parser??..

Answer / natasha,ashwni,smita,prajakta

Thank you..it helped us a lot :)

Is This Answer Correct ?    10 Yes 5 No

what is the difference between SAX Parser and DOM Parser??..

Answer / chaitheesh

sax is simple api for xml
it read the first xml data and get outputed backward is not
possible,
dom is doccument object model
through dom we can create a xml data as a tree and it is
loaded in memory so we can easily access the data

Is This Answer Correct ?    7 Yes 5 No

Post New Answer

More Struts Interview Questions

List some bundled validators?

0 Answers  


struts 1.3 features?

1 Answers   Integra, Zensar,


Can you explain the directory structure for a struts folder in brief ?

0 Answers  


What is actionservlet?

0 Answers  


what are the struts tags?

1 Answers  






How does interceptor work in struts2?

0 Answers  


What is role of actionservlet?

0 Answers  


What is struts in java with example?

0 Answers  


What is Struts2?

0 Answers  


What is struts and springs in java?

0 Answers  


How to create validations?what are struts validation components?

2 Answers  


What are apache struts?

0 Answers  


Categories