I want my app to read a XML开发者_如何学C via internet.
Also I want to keep the previously download xml so next time I may not need to download again until certain hours is passed or whatever period of time according to settings.
Do you recommend me to download it first and store locally before process it? Or should I process it while downloading (with libxml2 I guess)?
What do you usually with apps using remote XML?
Targeting 3.0 devices btw.
The libxml2
library has a SAX parser that you can use to process XML as it comes in, to reduce memory usage. If you use the DOM parser, you have to store the entire document in memory, which can be an issue for iPhone and iPod Touch devices.
Take a look at Apple's XMLPerformance sample application, which demonstrates how to use the SAX parser. It's a bit more complicated than the DOM approaches, but it will be faster and use less memory.
精彩评论