One aspect by which various types of parsers can be classified is whether they need to load the entire XML document into memory in front. Parsers based on the Document Object Model (DOM) do this: they parse XML documents into a tree structure, which can then be moved in memory to read its contents. This allows you to move the document in random order and provides some useful APIs that can be removed on top of the DOM, such as XPath, a path query language that was specifically designed to extract information from trees. Using only the DOM is not very useful, because its API is inconvenient, and it is expensive to always read everything in memory, even if you do not need it. Therefore, DOM parsers are in most cases not the best choice for XML parsing on Android.
There is a class of parsers that do not need to load a document in front. These parsers are stream-based, which means that they process the XML document while still reading it from a data source (Web or disk). It follows that you do not have random access to the XML tree, as to the DOM, because the internal representation of the document is not supported. The flow of parsers can be distinguished from each other. There are push parsers that when streaming a document access your application when they encounter a new element. SAX, fall into this class. Then there are pull parsers that look more like iterators or cursors: here the client must explicitly request that the next item be restored.
Source: Android in practice.
Quantum_VC
source share