I want to know the difference between the four above types (SAXPaser, XPath, DOM, XMLPullParse) and when should we use each one.
相关问题
- How can I create this custom Bottom Navigation on
- Illegal to have multiple roots (start tag in epilo
- Bottom Navigation View gets Shrink Down
- Correctly parse PDF paragraphs with Python
- How to make that the snackbar action button be sho
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Creating XML Elements without namespace declaratio
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Get Attribute Value From Simple XML Using JQuery /
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
So if you have very large files then you should use SAX parser since it will fire events and releasing them ,nothing is stored in memory ,and using SAX parser you can't access element in a random way there is no going back ! , but Dom let you access any part of the xml file since it keeps the whole file/document in memory .
see this article and you can get what you want by reading the Summary.
also check this link to view performance of different xml parser
Please check below links...
http://steveliles.github.com/comparing_methods_of_xml_parsing_in_android.html
http://xjaphx.wordpress.com/2011/11/01/android-xml-adventure-compare-xml-parsers/
http://www.ibm.com/developerworks/opensource/library/x-android/index.html
http://www.developer.com/ws/android/development-tools/Android-XML-Parser-Performance-3824221-2.htm
http://www.geekinterview.com/question_details/12797
(As Per above Article)
Both SAX and DOM are used to parse the XML document. Both has advantages and disadvantages and can be used in our programming depending on the situation
SAX:
DOM
If we need to find a node and doesnt need to insert or delete we can go with SAX itself otherwise DOM provided we have more memory.
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..Store the entire XML document into memory befor processing Slower at runtime Stored as an objects Programmatically easy to implement Ease of navigation and use,can traverse in any direction. We can insert or delete,alter nodes.
SAX : use when you want to access XML ( not alter XML)
Sequence of events It doesn't use any memory preferred for large documents.Doesn't store the XML in memory before processing 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,top to bottom traversing We can't insert or delete a node
XPATH: Xpath is useful when you only need a couple of values from the XML document and you know where to find them(you know the path of the data./root/item/challange/text)
XMLPullParser: Fast and requires less memory with DOM
Source: http://www.time2ask.com/ http://www.time2ask.com/Android/The-difference-among-SAX-ParserXPathDOMXMLPullParser/_2361836