Re: Noob question in regards to NSXMLParser
Re: Noob question in regards to NSXMLParser
- Subject: Re: Noob question in regards to NSXMLParser
- From: "Eric E. Dolecki" <email@hidden>
- Date: Tue, 07 Jun 2011 10:25:41 -0400
I went with the first solution and it works well enough for me. Anything
beyond this simple XML and I think I'd likely use a 3rd-party solution.
Thanks for the suggestion!
Google Voice: (508) 656-0622
Twitter: eric_dolecki XBoxLive: edolecki PSN: eric_dolecki
http://blog.ericd.net
On Tue, Jun 7, 2011 at 10:13 AM, Hank Heijink (Mailinglists) <
email@hidden> wrote:
> Two ways that I've used:
>
> 1. Keep a boolean isInCurrentConditions that you set when you start the
> current_conditions element and reset when you end that element. Then every
> time you enter a condition element you check the boolean to see if you are
> where you need to be in the hierarchy. This works well enough if your
> hierarchy is not too complicated and you only need to know about a couple of
> elements. If it does get complicated, you'll end up tracking a dozen
> booleans, which I don't recommend.
>
> 2. The complicated case: keep a stack of element names. Every time you
> enter one, you push it, and every time you leave you pop it (it pays to
> check what you're popping, just in case). Then, whenever you encounter a
> condition element, you check the stack to see if you're at the right place
> in the hierarchy.
>
> I'm sure there are other ways, but these have worked well for me.
>
> Hope this helps,
> Hank
>
> On Jun 7, 2011, at 10:03 AM, Eric E. Dolecki wrote:
>
> > I am fetching some XML weather from Google:
> >
> > <xml_api_reply version="1">
> > <weather module_id="0" tab_id="0" mobile_row="0" mobile_zipped="1"
> row="0"
> > section="0">
> > <forecast_information>
> > <city data="Framingham, MA"/>
> > <postal_code data="01701"/>
> > <latitude_e6 data=""/>
> > <longitude_e6 data=""/>
> > <forecast_date data="2011-06-07"/>
> > <current_date_time data="2011-06-07 12:38:31 +0000"/>
> > <unit_system data="US"/>
> > </forecast_information>
> > <current_conditions>
> > <condition data="Sunny"/>
> > <temp_f data="69"/>
> > <temp_c data="21"/>
> > <humidity data="Humidity: 66%"/>
> > <icon data="/ig/images/weather/sunny.gif"/>
> > <wind_condition data="Wind: NW at 3 mph"/>
> > </current_conditions>
> > <forecast_conditions>
> > <day_of_week data="Tue"/>
> > ...
> >
> > What I am really after is the current_conditions data. How can one
> specify
> > WHERE in the XML to use the attributes from? A lot of the information is
> > repeated in other nodes so I can't just check (if([elementName
> > isEqualToString:@"condition"]){) , how can I check if the current
> element is
> > within a specific tag? (In this case the parent is current_conditions)?
> >
> > Eric
> > _______________________________________________
> >
> > 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
> >
>
>
_______________________________________________
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