cancel
Showing results for 
Search instead for 
Did you mean: 

Disadvantages of SAX parser

Former Member
0 Kudos

tell me some disadvantages of the SAX parser.

Accepted Solutions (1)

Accepted Solutions (1)

prabhu_s2
Active Contributor
0 Kudos

One major problem that remains with the SAX parser is that the user who implements the “ProcessData” method has no control over the sequence in which different elements are processed. The processing sequence depends only on the sequence within the XML file.

source: http://notes.corewebprogramming.com/student/SAX.pdf

One major problem that remains with the SAX parser is that the user who implements the “ProcessData” method has no control over the sequence in which different elements are processed. The processing sequence depends only on the sequence within the XML file.

source: http://www.gamasutra.com/features/20060427/luerig_02.shtml

Google for more

Former Member
0 Kudos

not sure if it is a demerit

but the diff between DOM and SAX is in DOM a tree is built and can be moved up and down but SAX only one way, once

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Sankar

Disadvantage of SAX are as follows

1)SAX is an event-driven push model for processing XML. It is not a W3C standard,

2)Rather than building a tree representation of an entire document as DOM does, a SAX parser fires off a series of events as it reads through the document.

3)The disadvantage of SAX is that you have to implement the event handlers to handle all incoming events. You must maintain this event state in your application code. Because the SAX parser does not communicate meta-information such as DOM's parent/child

4) you have to keep track of where the parser is in the document hierarchy. Thus, the more complex your documents are, the more complex your application logic becomes.

5)Even though there is no need to load the entire document into memory at one time, a SAX parser still needs to parse the whole document, as with DOM.

6)Probably the biggest problem facing SAX is that it does not have built-in document navigation support such as that provided by XPath. This, coupled with its one-pass parsing, means there is no random access support.

7)This limitation also shows up in namespaces: Elements that have inherited namespaces will not be annotated. These limitations make SAX a poor choice for manipulating or modifying a document

    • SAX (Simple API for XML) it is probably the most complete and accurate method so far.

This is used for XML documents.The SAX classes provide an interface between the input streams from which XML documents are read and the client software which receives the data made available by the parser. The parser browses through the whole document and fires events every time it recognizes an XML construct (e.g. it recognizes a start tag and fires an event – the client software is notified and can use this information… or not).

For more details you can refer to link

http://www.oracle.com/technology/oramag/oracle/03-sep/o53devxml.html

hope it may help you

Thanks

sandeep

PS: if helpful reward points

Former Member
0 Kudos

Hi

SAX -> Simple API For XML. -> Allows you to parse through a XML document. Doesn't consume any memory. But the message can be parsed only once from top to bottom. It Has evolved by contributions made by group of people.Its an open architecture.

DOM -> Document Object Model -> Its designed by W3C. Consumes Memory as the message will be loaded. Allows parsing of document in both way top down and bottom up.

SAX parser is something that parses your XML one after the other, and so is not processor intensive. But, it is not exactly easy to develop either.

DOM is easier to use with lots of classes to help you create nodes and elements, but , DOM is very processor intensive.

Thanks