androidsaxparserdomparser

Difference in doing Android XML Parsing using DOM Parser and SAX Parser


I would like to know what exact advantage is gained in doing Android XML Parsing using DOM Parser and SAX Parser?

Is it like DOM parser is advantageous than SAX Parser or vice-versa?


Solution

  • SAX Parsing is the Best one to implement than DOM, see the difference between these two in the following:

    DOM:

    1. The Nodes are in the form of Tree Structure
    2. Memory: It Occupies more memory, DOM is only preffered in the case of small XML documents
    3. Slower at runtime
    4. Stored as an objects
    5. Programmatically easy to implement
    6. Ease of navigation and use.

    SAX:

    1. Sequence of events
    2. It doesn't use any memory preferred for large documents.
    3. Faster at runtime, because of the above mentioned point.
    4. Objects are to be created.
    5. Need to write code for creating objects
    6. In SAX Backward navigation is not possible as it sequentially processes the document