Re: Parsing common elements between xml documents
Re: Parsing common elements between xml documents
- Subject: Re: Parsing common elements between xml documents
- From: Jens Alfke <email@hidden>
- Date: Sat, 17 Apr 2010 17:58:46 -0700
On Apr 17, 2010, at 12:42 PM, Malayil George wrote:
> But, I figure it would be easier if I could set
> up a parser that would parse B into it's object and return it. So, while
> parsing A, when I encounter element B, I would like to hand-off the entire B
> element to my B parser and have it return object B. This way, while parsing
> doc D, I could do the same thing (and not have to duplicate code for parsing
> B) and my code is more readable. However, I am not able to figure out how to
You can do this with a stream-based parser but it takes a bit of work. You keep a stack of which object you’re currently building, and when you finish an element you pop the corresponding object and hand it to the new top object, to store a reference to it.
This sort of thing is easier with a DOM-based parser where you can inspect the entire tree of objects at once, but the Cocoa one (NSXMLDocument) isn’t available on iPhone for some reason.
—Jens_______________________________________________
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