Difference Between: SAX Parser, XPath, DOM, XMLPullParser

I want to know the difference between the four types (SAXPaser, XPath, DOM, XMLPullParse) and when we should use them.

+7
source share
3 answers

SAX Parsing is better for implementation than DOM, see the difference between the two in the following:

Dom

The nodes are in the form of a memory tree structure: it takes up more memory, the DOM is used only for small XML documents. Slower at run time. Saved as an object. Software easy to implement Ease of navigation and use.

Sax

Sequence of events He does not use the memory preferred for large documents. Faster at runtime, due to the above item. Objects must be created. You must write code to create objects In SAX, reverse navigation is not possible, because it sequentially processes the document

So, if you have very large files, you should use a SAX parser, since it will trigger events and release them, nothing is stored in memory, and with the help of the SAX analyzer you cannot access the element randomly,!, But Dom allows you to access any part of the xml file as it saves the entire file / document in memory.

see the article and you can get what you want by reading the Summary .

also check this link to view the performance of various xml parser

enter image description here

+9
source

Please check the links below ...

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 mentioned above)

Both SAX and DOM are used to parse an XML document. Both have advantages and disadvantages and can be used in our programming depending on the situation.

SAX:

  • Parses node to node
  • Does not store XML in memory
  • We cannot insert or delete node
  • Top down

Dom

  • Saves the entire XML document in memory before processing
  • Takes up more memory
  • We can insert or delete nodes
  • Moving in any direction.

If we need to find a node and do not need to insert or delete, we can go with SAX, otherwise the DOM, provided that we have more memory.

+3
source

Dom

The nodes are in the form of a memory tree structure: it takes up more memory, the DOM is used only in case of small XML documents. Store the entire XML document in memory before processing. Slower at run time. Saved as an object. Software easy to implement. Easy navigation and use can go in any direction. We can insert or delete, change nodes.

SAX: use when you want to access XML (do not modify XML)

Sequence of events He does not use the memory preferred for large documents. Do not store XML in memory before processing Faster at runtime, due to the above point. Objects must be created. You must write code to create objects In SAX, reverse navigation is not possible, because it sequentially processes the document, moving from top to bottom. We cannot insert or delete a node

XPATH: Xpath is useful when you only need a few values ​​from an XML document and you know where to find them (you know the data path. / Root / item / challange / text)

XMLPullParser: Fast and requires less memory with the DOM

Source: http://www.time2ask.com/ http://www.time2ask.com/Android/The-difference-among-SAX-ParserXPathDOMXMLPullParser/_2361836

+2
source

All Articles