问题
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?
Please clarify.
Thanks,
Sen
回答1:
Hi SAX Parsing is the Best one to implement than DOM, see the difference between these two in the following:
DOM
- The Nodes are in the form of Tree Structure
- Memory: It Occupies more memory, DOM is only preffered in the case of small XML documents
- Slower at runtime
- Stored as an objects
- Programmatically easy to implement
- Ease of navigation and use.
SAX
- Sequence of events
- It doesn't use any memory preferred for large documents.
- Faster at runtime, because of the above mentioned point.
- Objects are to be created.
- Need to write code for creating objects
- In SAX Backward navigation is not possible as it sequentially processes the document
来源:https://stackoverflow.com/questions/4500297/difference-in-doing-android-xml-parsing-using-dom-parser-and-sax-parser