Parsers used in Android
Which all parsers are used in Android for XML parsing? Right now I know only SAX, XMLPullParser and DOM parsers. It will be really grea开发者_运维百科t if someone can tell the efficiency comparison for parsers used.
Thanks,
Stonethis guy has talked exactly for what you have asked.
http://www.ibm.com/developerworks/opensource/library/x-android/
though about efficiency you can find it while he is closing
SAX:
1. Parses node by node
2. Doesnt store the XML in memory
3. We cant insert or delete a node
4. Top to bottom traversing
DOM
1. Stores the entire XML document into memory before processing
2. Occupies more memory
3. We can insert or delete nodes
4. Traverse in any direction.
check this:
SAX parser vs XMLPull parser
http://www.developer.com/ws/article.php/3824221/Android-XML-Parser-Performance.htm
http://www.differencebetween.net/technology/difference-between-sax-and-dom/
Another XML Parser that I've found very useful is the Simple Java XML Parser (SJXP) available at http://www.thebuzzmedia.com/software/simple-java-xml-parser-sjxp/. It uses the XPP3 pull parser, and aims for efficiency while still being very simple to use.
The source code is also available, with great inline commenting if you want to see how it works.
精彩评论