jump to navigation

Difference between SAX and DOM parsers? December 28, 2006

Posted by Allu in JAVA.
trackback

SAX Parser:

·        A SAX (Simple API for XML) parser does not create any internal structure. Instead, it takes the occurrences of components of an input document as events, and tells the client what it reads as it reads through the input document.

·        A SAX parser serves the client application always only with pieces of the document at any given time.

·        A SAX parser, however, is much more space efficient in case of a big input document (because it creates no internal structure). What’s more, it runs faster and is easier to learn than DOM parser because its API is really simple. But from the functionality point of view, it provides a fewer functions, which means that the users themselves have to take care of more, such as creating their own data structures.

DOM Parser:

·        A DOM (Document Object Model) parser creates a tree structure in memory from an input document and then waits for requests from client.

·        A DOM parser always serves the client application with the entire document no matter how much is actually needed by the client.

·        A DOM parser is rich in functionality. It creates a DOM tree in memory and allows you to access any part of the document repeatedly and allows you to modify the DOM tree. But it is space inefficient when the document is huge, and it takes a little bit longer to learn how to work with it.

About these ads

Comments»

1. prasad - March 20, 2007

hi sir,
whatever u giving the suggestions to my questions. its very nice.
thanks to u.

with regards,
prasad.

java blog - October 2, 2012

I agree, great stuff. By the here are few more differences between DOM and SAX parser in Java.

2. dhamu - October 4, 2007

It is really good explanation.

3. hema - October 6, 2007

sir, can i know what is the exact difference between API and PARSER?

4. Rajeev - December 3, 2007

Hello sir
What u giving ,it very good.

5. srujana - August 16, 2008

hello sir,
thank u very much for giving valuable information on parsers

6. sophea2csl - February 11, 2009

Thank you very much for your explanation.

7. Ashu - February 17, 2009

Pls some one clarify client request in above detail.

8. jzhang - November 25, 2009

You may also want to look at vtd-xml, the latest and most advanced XML processing
API

vtd-xml

9. v.satish - May 24, 2010

For reading of large xml file, which one is good sir(either DOM or SAX).

10. Sameer - May 24, 2010

SAX for large files should be an obvious choice, unless you have a very bing chunk of memory with you.

11. swarna - July 28, 2010

thank u…..
its really very helpful.

12. balu - November 8, 2010

thank u sir

13. mazeed - November 24, 2010

sir please give examples about that above topic
it is very helpful to the others and it can be clarified

14. ajaykumarijjada - April 18, 2011

thanku

15. muralikumar - July 19, 2011

thk u
its really useful for the interview point of view

16. kiran kumar - August 12, 2011

than you very short and good explanation

17. Som - August 17, 2011

thanks…. it gives a proper idea about both… :)

18. prabha - September 16, 2011

very good

19. sris - November 1, 2011

good one

20. Ranganath - November 27, 2011

goof one

21. kavya sree - January 26, 2012

tanx for the post

22. adhityaa - March 20, 2012

super

23. sachin ponia - March 22, 2012

thx u dis is literally gud nd more helpful 4 me

24. narayan - March 30, 2012

gud one

25. Prachi - April 25, 2012

Quite a good explainantion :)

26. Ramesh - May 15, 2012

Hai sir,
This is very usefull for me.

27. hhhhh - June 22, 2012

nice explaination

28. sandeep - June 23, 2012

very use ful information sir :-)very very thank ful to you.:)sir , could you please tell me how to use there parsing techniques in android ?where to place them android tree structure ?

29. sanjay jhawar - July 31, 2012

this is realy a very clear explanation of difference between sax and dom parser… thankyou

30. madhu - August 6, 2012

It is very clear explaination

31. virus - September 5, 2012

Is any one tell me plz that sax parser and Expart parser both are same or differnet and how?

32. Laura - October 22, 2012

Have you tired Expresso XML Parser? It’s a high performance parser that has a graphical interface. You log onto a website and parse your XML file online so you can create parsing rules without writing code. Then you link up to your existing project using their client code. At the moment they have client code in java and javascript. They have a free developer version at http://www.sxml.com.au

33. Phaneendra - October 23, 2012

Thanks for valuable information sir

34. Erwin - November 17, 2012

Thank you so much for this straight forward comparison.

35. Yogesh Shisode - December 10, 2012

really nice explanation

36. Applying SAX or DOM to Xml using SOAP in android? : Android Community - For Application Development - February 20, 2013

[...] Here you are reading the data, hence you should be using SAX parser only. DOM is generally used to read/ write XML file. See the diff. over here. [...]

37. Satish - May 23, 2013

great stuff

38. venkat - May 23, 2013

simply gud

39. Samuel - July 7, 2013

How do i convert an xml file to html?


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: