XML namespace and Attributes AGAIN!
Why can't APIs just use standard XML structure and not complicate things with attributes and namespaces.
Anyway I'm once again struggling with a weather XML feed and namespaces.
the XML looks like:
Code:
<aws:weather xmlns:aws="http://www.aws.com/aws">
<aws:api version="2.0"/>
<aws:WebURL>http://weather.weatherbug.com/GA/Marietta-weather.html?ZCode=Z5546&Units=0&stat=MRTTS</aws:WebURL>
<aws:InputLocationURL>http://weather.weatherbug.com/GA/Marietta-weather.html?ZCode=Z5546&Units=0</aws:InputLocationURL>
<aws:ob>
<aws:ob-date>
<aws:year number="2009"/>
<aws:month number="11" text="November" abbrv="Nov"/>
<aws:day number="19" text="Thursday" abbrv="Thu"/>
<aws:hour number="10" hour-24="22"/>
<aws:minute number="10"/>
<aws:second number="00"/>
<aws:am-pm abbrv="PM"/>
<aws:time-zone offset="-5" text="Eastern Standard Time" abbrv="EST"/>
</aws:ob-date>
<aws:requested-station-id/>
<aws:station-id>MRTTS</aws:station-id>
<aws:station>Tritt Elementary School Foundation</aws:station>
<aws:city-state zipcode="30062">Marietta, GA</aws:city-state>
<aws:country>USA</aws:country>
<aws:latitude>34.0172233581543</aws:latitude>
<aws:longitude>-84.420280456543</aws:longitude>
<aws:site-url>http://www.cobbk12.org/schools/es/schtritt/</aws:site-url>
<aws:aux-temp units="&deg;F">67</aws:aux-temp>
<aws:aux-temp-rate units="&deg;F">0</aws:aux-temp-rate>
<aws:current-condition icon="http://deskwx.weatherbug.com/images/Forecast/icons/cond017.gif">Fair</aws:current-condition>
<aws:dew-point units="&deg;F">39</aws:dew-point>
<aws:elevation units="ft">1050</aws:elevation>
<aws:feels-like units="&deg;F">47</aws:feels-like>
<aws:gust-time>
<aws:year number="2009"/>
<aws:month number="11" text="November" abbrv="Nov"/>
<aws:day number="19" text="Thursday" abbrv="Thu"/>
<aws:hour number="12" hour-24="12"/>
<aws:minute number="35"/>
<aws:second number="00"/>
<aws:am-pm abbrv="PM"/>
<aws:time-zone offset="-5" text="Eastern Standard Time" abbrv="EST"/>
</aws:gust-time>
<aws:gust-direction>SW</aws:gust-direction>
<aws:gust-speed units="mph">12</aws:gust-speed>
<aws:humidity units="%">74</aws:humidity>
<aws:humidity-high units="%">93</aws:humidity-high>
<aws:humidity-low units="%">44</aws:humidity-low>
<aws:humidity-rate>4</aws:humidity-rate>
<aws:indoor-temp units="&deg;F">78</aws:indoor-temp>
<aws:indoor-temp-rate units="&deg;F">0</aws:indoor-temp-rate>
<aws:light>0.0</aws:light>
<aws:light-rate>0.0</aws:light-rate>
<aws:moon-phase moon-phase-img="http://api.wxbug.net/images/moonphase/mphase01.gif">-2</aws:moon-phase>
<aws:pressure units=""">30.14</aws:pressure>
<aws:pressure-high units=""">30.17</aws:pressure-high>
<aws:pressure-low units=""">30.10</aws:pressure-low>
<aws:pressure-rate units=""/h">0.00</aws:pressure-rate>
<aws:rain-month units=""">4.08</aws:rain-month>
<aws:rain-rate units=""/h">0.00</aws:rain-rate>
<aws:rain-rate-max units=""/h">0.00</aws:rain-rate-max>
<aws:rain-today units=""">0.00</aws:rain-today>
<aws:rain-year units=""">45.61</aws:rain-year>
<aws:temp units="&deg;F">47.2</aws:temp>
<aws:temp-high units="&deg;F">60</aws:temp-high>
<aws:temp-low units="&deg;F">39</aws:temp-low>
<aws:temp-rate units="&deg;F/h">-1.6</aws:temp-rate>
<aws:sunrise>
<aws:year number="2009"/>
<aws:month number="11" text="November" abbrv="Nov"/>
<aws:day number="19" text="Thursday" abbrv="Thu"/>
<aws:hour number="7" hour-24="07"/>
<aws:minute number="13"/>
<aws:second number="49"/>
<aws:am-pm abbrv="AM"/>
<aws:time-zone offset="-5" text="Eastern Standard Time" abbrv="EST"/>
</aws:sunrise>
<aws:sunset>
<aws:year number="2009"/>
<aws:month number="11" text="November" abbrv="Nov"/>
<aws:day number="19" text="Thursday" abbrv="Thu"/>
<aws:hour number="5" hour-24="17"/>
<aws:minute number="32"/>
<aws:second number="02"/>
<aws:am-pm abbrv="PM"/>
<aws:time-zone offset="-5" text="Eastern Standard Time" abbrv="EST"/>
</aws:sunset>
<aws:wet-bulb units="&deg;F">43.502</aws:wet-bulb>
<aws:wind-speed units="mph">0</aws:wind-speed>
<aws:wind-speed-avg units="mph">2</aws:wind-speed-avg>
<aws:wind-direction>WNW</aws:wind-direction>
<aws:wind-direction-avg>WNW</aws:wind-direction-avg>
</aws:ob>
<ignoreWhitespace>true</ignoreWhitespace>
</aws:weather>
I've found an example at http://animateinexile.blogspot.com/2...on-in-xml.html
but when I try this I get an error that AS is expecting a variable at that line(xmlData..bug::["temp-high"]);).
PHP Code:
function loadXML(e:Event){
var xmlData:XML = new XML(e.target.data);
xmlData.ignoreWhitespace=true;
var bug:Namespace = new Namespace("http://www.aws.com/aws");
trace(xmlData..bug::["temp-high"]);
//trace(xmlData);
}
function io_error(e:Event){
trace("error");
}