Comparison of SAX,DOM,PULL
SAX,DOM,PULL each have their own characteristics, the specific operation of XML how to choose it.
1. Memory Footprint
This is a fundamental issue. Because of the limited performance of Android phones compared to current applications, the memory footprint of programs directly affects the speed at which XML is parsed. At this point,SAXandPull are better suited to Android phone development by parsing them with less memory than the DOM .
2. Programming Method
SAX uses event-driven, which invokes a user-written method when the corresponding event is triggered. In other words, each class of XML is parsed to write a new processing class that is appropriate for the class of XML. This is clearly not a good solution, even though it is excellent at parsing speed. And this,DOM , is the norm for the consortium. So it is known and used by more programmers. So in the development process, there is not much difficulty. Pull is a small, even unknown parser, but by the above introduction and examples, we should be able to see the simplicity of it.
3. Access and Modification
As a result of streaming parsing, this means that they cannot be randomly accessed as a DOM , any one of the nodes in the XML. Also,SAX does not provide an API for adding nodes to the document, nor does it remove and modify the content of the document.
4. How to access
This is the root cause of the speed of their resolution. If SAX and Pull are likened to Islands, soon but in a cursory reading, DOM is a word-reading, slow, but memorable. Also note here thatSAX,Pull parsing is synchronized, where the parser reads it and handles it. The DOM is already parsing the file to allow the user to extract information that is of interest in the XML.
Summary:
For memory footprint, it is recommended that you use SAX or Pull to work. But according to how they work: if you just need information about the last few nodes in the XML, or if you're retrieving XML files repeatedly. So basically there is no difference in performance between the three, but at this point,SAX 's processing class makes the program appear bloated compared to other implementations. So, want to do a high-performance Android software, or to more analysis, choose the right tools to play its role.