Optimal way to save/parse XML on iPhone

This is my first question so I will do my best to conform to the question guidelines.

I am developing an iPhone app that parses and XML feed to be displayed in a table. Parsing is not a problem but I am not sure of the best way to optimize loading times after initial run of the app.

Here is the different approaches that I am considering:

  1. Parse the XML feed each time the application is loaded. Easy way but possibly longer loading time each run of the app.

  2. Grab the feed and store it locally (as .xml) then parse locally. Then, each time the app is opened, make an http call to see if the feed has been changed. If not, parse locally. If so, download the new feed and parse locally. The initial loading time will be longer but could be cut down on later runs (if the feed as not been updated). This option will be beneficial if the user has a bad signal but needs to see the data.

  3. Parse the feed and store it into a local sqlite db. Then, each time the app is opened, make an http call the see if the feed has been changed. If so, detect which objects have been added/removed and alter local db accordingly. If not, load data from local db. This might be the best option but I am not sure how long finding the changes will take.

My feed is only about 100 or so items, each with roughly 20 fields.

Initial parsing time:

  • Roughly 4-5sec with full bars.
  • Roughly 5-7sec with 3 bars.

Any insight as to which option would work best would be very much appreciated.

Answers


I think the frequency of the xml data changing should be a factor. If its only going to change once a day/week? Id load it, save it, and check for updates. If update exists download new and overwrite old.


Third solution is clearly the best and it will allow your app to work offline and start quickly. To detect the change, you can simply store a MD5 of the xml file in database and match it against the MD5 of the new XML file. If data has changed, then simply discard all previous data.


Need Your Help

Zsh tab completion: Is there any plugin or feature that can allow for a MRU tab-completion scheme?

shell autocomplete terminal zsh tab-completion

I find myself doing stuff like typing the last part of a command name because the beginning of it gets completed with other commands. Of course most other shells can't even complete stuff in this way

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.