On Wed, Nov 12, 2008 at 3:41 PM, Ariel Rodriguez <[EMAIL PROTECTED]> wrote: > I'm playing with a REST implementation. Basically, i am following this > tutorial: > http://developer.apple.com/webapps/articles/creatingrestfulclients.html > And, as you can see, the xml produced by the app is this: > <?xml version="1.0" encoding="UTF-8"?> <CountryData> <country> <id>37</id> > <country>Canada</country> <gdp>1274000000000</gdp> <iso_code>ca</iso_code> > </country> </CountryData> > Where each country has a country tag (the name). My question is how to parse > an xml where there are nested tags with the very same name. > I've tried to catch the country tag on > parser:didEndElement:namespaceURI:qualifiedName: with an > if([elementName isEqualToString:@"country"]) {} > but this catch the parent and nested country tag. There is way to know the > difference?
This is a classic example of where to use a finite state machine: <http://en.wikipedia.org/wiki/Finite_state_machine> Basically, you have an initial state and then an "inside country" state. Then inside your parser:didEndElement:namespaceURI:qualifiedName: you behave differently based on the current state. _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]