Re: Parsing xml files in Cocoa applications
Re: Parsing xml files in Cocoa applications
- Subject: Re: Parsing xml files in Cocoa applications
- From: Nicko van Someren <email@hidden>
- Date: Fri, 31 Oct 2008 14:56:51 +0000
On 30 Oct 2008, at 09:29, Paul Reilly wrote:
There is also some good sample code on the iPhone Developer site,
called
SeismicXML which shows how to parse an XML document.
It is worth noting that while the event-driven NSXMLParser class is
available on the iPhone, NXSMLDocument and its friends for the XML DOM
are NOT available on the iPhone. If you have existing code that uses
NSXMLDocument which you want to port to the iPhone you shall need to
rework the code or write classes to emulate the necessary functionality.
Unless you know that you need to keep all the information in your XML
document for use later you can usually save quite a lot of space by
using the event model and being careful which parts of the data you
bother keeping. I suspect that in the memory-constrained world of the
iPhone this was the rationale behind forcing people to use the event-
driven model. You do however need to be cautious when using the event
driven parser in a memory-constrained environment to make sure that
you don't leave lots of objects in the auto-release pool after your
event calls. If you have a large document which you parse and filter
down to some much smaller data set but on the way leave a lot of trash
in the auto-release pool you can find the iPhone app running out of
memory before you've finished parsing the document. If you are unsure
you can always push a local auto-release pool at the start of each of
the event callbacks which do any hard work and pop them again before
you return from the callback.
Cheers,
Nicko
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden