Question

I need to parse the Yahoo Weather RSS feed for a place, like http://weather.yahooapis.com/forecastrss?w=44418&u=c for example, to get the high, low, current temperature and the weather image eg. sun and clouds image, for the current day.

I'd like to do this in Cocoa (Mac).

Any help would be appreciated, thanks!

Was it helpful?

Solution

You have two ways, how you could solve this:

Use a wrapper

If you wan't to solve the problem the easy way, you could use a soloution someone already programmed for you for example this simple wrapper. The problem is that this wrapper just fetches basic things like temperature etc. If you want more informations you'll have to extend the code, but I think that shouldn't be a big problem.

Here is an usage example:

#import "SCYahooWeatherParser.h"
// ...
SCYahooWeatherParser *parser = [[SCYahooWeatherParser alloc] initWithWOEID:woeid weatherUnit: SCWeatherUnitCelcius];
SCYahooWeather *result = [parser parse];
// now you can handle the parameters of result by yourself.

Use a XML Parser

If you wan't you can solve it also the hard, but cleaner way. You can Download the XML from their servers and parse it with a XML Parser. For this I recommend you to first read the documentation of the Yahoo weather API. Than when you know what you're doing I recommend you to use TouchXML for parsing the XML data, because this is a very good XML Parser, which is also use by a lot of people.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top