Q:

NSXMLParser iPhone Question

I have an XMLParser class which uses NSXMLParser (event-driven) This is being called by an external class (MyVC.m), passing the web service API URL each time.
Here is my question; I have 2 options to parse

If I pass URL as http://xyz.com/sub1/ I get a complete XML file and then will have to parse for some specific nodes
If pass URL as http://xyz.com/sub1/data I get only the data that I require

While option 2 seems to be good, the problem is I am looking for 3-4 data points and so is it better if NSXMLParser is called least no. of times, as in option 1 OR it is not that expensive to have it called multiple times, like in option 2.

A:

Although it's not possible to answer your question based on what you've said, a key part of your question is 'I am looking for 3-4 data points' which implies you can't just ask for the specific items you're looking for without some sort of search through the data.
In general, you should minimise both the number of requests, and the amount of data transferred.  There isn't enough information here to say whether the signal/noise ratio (so to speak) means that it's more efficient to transfer the whole lot, or just the items of interest.
If you're interested in most of the data returned, I'd go with returning the whole caboodle. If you're interested in a small subset, and can identify it reasonably efficiently (without returning the whole set) then I might try just fetching those items.
If you wanted to get really fancy, you could adapt the approach based on whether you're on wifi or EDGE, but the return on that is unlikely to be worth the investment of coding / maintenance required ;-)
Good luck.

