With so many Xml parsers existing on the mobile front it is pretty difficult to make the choice. Let’s look at each one of them in order to discuss the pros and cons. XML parsing is a 3 stage process,

1.Stage 1–>Input Processing–>Parser validates the input XML.

2.Stage 2–>Handling/Processing of incoming XML resource.

3.Stage 3–>Output Generation–>The Parsing application generates model of the document to be generated.

Now Let’s look at a few parsers already present and how well they handle this 3 stage process,

A. The SAX parser(aka Simple Api for Xml)–>Falls in the category of “Push Parsers”.These types of parsers push the application i.e. they drive the application rather than the application driving them. For each type of construct or element handled in the xml the parser throws an event which the application is required to handle. Now, event handling for each and every construct present in the XML definitely requires an amount of processing power that is beyond the reach of various CLDC devices. So, this results in a potential limitation.

B. DOM Parser, during stage 3 of the XML parsing, will create a tree like data structure in the memory, as output, which will persist in memory. This parser falls in the category of model parser and definitely has some memory constraints.

C.To overcome the parsing limitations due to model and push parser we’ve another type of parser implementation called as a Pull Parser . A pull parser is the one where the application drives the parser. As opposed to the push parser which reads the whole XML in one go, the pull parser just reads a small part of the XML at a time and the application can pull out the parsed XML constructs one by one according to its needs. This results in minimal memory constraints and  processing power.