Although our last application is working pretty good with SAX Parser, but as i said i'm gonna use Pull Parser instead, to see how it works, as far as i know Pull Parsing is a bit slower that SAX parsing but it gives the ability to stop parsing in the middle of a document and this means that Pull Parsing would be well suited in a situation in which we just need some portions of XML and not the whole of it.
In our application we need the whole xml but i think now that we are dealing with XML parsing it would be a good opportunity to dig into PullParser method and draw a comparison between these two XML parsing methods.(you can also use DOM parsing, but i reckon it's safe to say that you shouldn't ever use it unless you really have to).
Here is our Pull Parser class:
I added some kind of filtering to our parsing process because I though it was so silly to extract all those values and store them in memory without even using them.so let's just store those information that is required and
simply just skip those ones we are not interested in.
Our FecherThread's run() method will also gotta be changed :
we can also get rid of executeAndParse() method since we no longer need it.
Done,that's it.... easy, wasn't it? now we are familiar with both SAX Parsing
and Pull Parsing in Android.