How To Read NOAA XML "weather-summary" Attribute?
Can someone help with Flash CS6 ActionScript 3 E4X syntax for reading National Weather Service’s XML feed (National Weather Service)?
I’ve been able to address most of the needed fields; but, XML attribute "weather-summary" is driving me to drink! Looping, I can locate it, but results always come back blank. Any help is appreciated. I’ve tried a number of approaches including:
for each(var elemParamters:XML in rssXML.data.(@type == "current observations").elements("parameters")) {
:
:
for each (var elemWeather:XML in elemParamters.weather.elements("weather-conditions") ) {
if ( elemWeather.hasOwnProperty("@weather-summary") ) {
currentConditions = elemWeather.("@weather-summary");
currentConditions = elemWeather.("@weather-summary[0]");
trace("\n elemWeather = {" + elemWeather +"}");
}
}
trace("\n currentConditions? = {" + currentConditions +"}");
:
:
Sample XML:
<dwml>
<data>
:
:
:
</data>
<data type="current observations">
<location>
<location-key>point1</location-key>
<point latitude="39.11" longitude="-84.42"/>
<area-description>Cincinnati, Cincinnati Municipal Airport Lunken Field, OH</area-description>
<height datum="mean sea level" height-units="feet">482</height>
</location>
<moreWeatherInformation applicable-location="point1">http://www.nws.noaa.gov/data/obhistory/KLUK.html</moreWeatherInformation>
<time-layout time-coordinate="local">
<layout-key>k-p1h-n1-1</layout-key>
<start-valid-time period-name="current">2015-04-29T13:53:00-04:00</start-valid-time>
</time-layout>
<parameters applicable-location="point1">
<temperature type="apparent" units="Fahrenheit" time-layout="k-p1h-n1-1">
<value>65</value>
</temperature>
<temperature type="dew point" units="Fahrenheit" time-layout="k-p1h-n1-1">
<value>43</value>
</temperature>
<humidity type="relative" time-layout="k-p1h-n1-1">
<value>45</value>
</humidity>
<weather time-layout="k-p1h-n1-1">
<name>Weather Type, Coverage, Intensity</name>
<weather-conditions weather-summary="Partly Cloudy"/>
<weather-conditions>
<value>
<visibility units="statute miles">10.00</visibility>
</value>
</weather-conditions>
</weather>
<conditions-icon type="forecast-NWS" time-layout="k-p1h-n1-1">
<name>Conditions Icon</name>
<icon-link>http://forecast.weather.govnewimages/medium/sct.png</icon-link>
</conditions-icon>
<direction type="wind" units="degrees true" time-layout="k-p1h-n1-1">
<value>999</value>
</direction>
<wind-speed type="gust" units="knots" time-layout="k-p1h-n1-1">
<value>15</value>
</wind-speed>
<wind-speed type="sustained" units="knots" time-layout="k-p1h-n1-1">
<value>5</value>
</wind-speed>
<pressure type="barometer" units="inches of mercury" time-layout="k-p1h-n1-1">
<value>29.84</value>
</pressure>
</parameters>
</data>
</dwml>
