Actionscript:
-
var temp:Number;
-
var weatherData:XML;
-
var yweather:Namespace;
-
-
var zipcode:String="11211";
-
var units:String = "f"; // "f" or "c" for Fahrenheit or Celsius
-
-
var yahooURL:String = "http://weather.yahooapis.com/forecastrss?p=" + zipcode + "&u=" + units;
-
-
var yahooWeather:URLLoader = new URLLoader();
-
-
yahooWeather.load(new URLRequest(yahooURL));
-
yahooWeather.addEventListener(Event.COMPLETE, onLoaded);
-
-
function onLoaded(evt:Event):void {
-
-
weatherData=new XML(evt.target.data);
-
yweather = weatherData.namespace("yweather");
-
-
temp = weatherData.channel.item.yweather::condition.@temp;
-
-
trace(temp);
-
}
This snippet comes from a student question about how to get the temperature from yahoo weather.
You could use this snippet to get lots of additional information based on a zipcode... like latitude, longitude, humidity, wind chill etc... The trickiest part of this code is the Namespace stuff... which I find generally annoying... probably just because I'm not used to it.
You can read some detailed info about the content contained in the RSS file here.