开发者

NSXMLParser iPhone Question

开发者 https://www.devze.com 2023-02-05 11:01 出处:网络
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.

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

  1. 开发者_开发技巧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

  2. 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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号