4 Replies Latest reply on May 31, 2016 3:34 PM by gsee RSS
    gsee Apprentice

    Reading xml from WeatherUnderground

    Hi,

     

    I want to replace an existing weather service (from yahoo) with a WeatherUndergroup API.

    I haven't been able to get my javascript code to actually read any of the current observation data, it just returns an empty result.

     

    var API = me.WeatherUndergroundAPI;
    var features = 'forecast';
    var queryLocation = '30009';
    var format = 'xml';
    var url = 'http://api.wunderground.com/api/' + API + '/' + features + '/'  + '/q/' + queryLocation + '.' + format
    var params = {
        url: url,
        timeout : 60
    };
    var xmlPage = Resources["ContentLoaderFunctions"].LoadXML(params);
    var params = {
        infoTableName : "InfoTable",
        dataShapeName : "WeatherForecast"
    };
    me.WeatherHumidity = xmlPage.curren t_observation.relative_humidity;
    result = xmlPage.current_observation.relative_humidity;
    

     

     

     

    I'm trying to read from this xml:

     

    <response>

    <version>0.1</version>

    <termsofService>

    http://www.wunderground.com/weather/api/d/terms.html

    </termsofService>

    <features>

    <feature>forecast</feature>

    <feature>geolookup</feature>

    <feature>conditions</feature>

    </features>

    <location>...</location>

    <current_observation>

    <estimated></estimated>

    <station_id>KGAALPHA22</station_id>

    <observation_time>Last Updated on May 4, 12:39 PM EDT</observation_time>

    <observation_time_rfc822>Wed, 04 May 2016 12:39:43 -0400</observation_time_rfc822>

    <observation_epoch>1462379983</observation_epoch>

    <local_time_rfc822>Wed, 04 May 2016 12:39:55 -0400</local_time_rfc822>

    <local_epoch>1462379995</local_epoch>

    <local_tz_short>EDT</local_tz_short>

    <local_tz_long>America/New_York</local_tz_long>

    <local_tz_offset>-0400</local_tz_offset>

    <weather>Mostly Cloudy</weather>

    <temperature_string>65.7 F (18.7 C)</temperature_string>

    <temp_f>65.7</temp_f>

    <temp_c>18.7</temp_c>

    <relative_humidity>57%</relative_humidity>

    <wind_string>From the West at 4.2 MPH Gusting to 6.8 MPH</wind_string>

    <wind_dir>West</wind_dir>

    <wind_degrees>270</wind_degrees>

    <wind_mph>4.2</wind_mph>

    <wind_gust_mph>6.8</wind_gust_mph>

    <wind_kph>6.8</wind_kph>

    <wind_gust_kph>10.9</wind_gust_kph>

    <pressure_mb>1009</pressure_mb>

    <pressure_in>29.80</pressure_in>

    <pressure_trend>0</pressure_trend>

    <dewpoint_string>50 F (10 C)</dewpoint_string>

    <dewpoint_f>50</dewpoint_f>

    <dewpoint_c>10</dewpoint_c>

    <heat_index_string>NA</heat_index_string>

    <heat_index_f>NA</heat_index_f>

    <heat_index_c>NA</heat_index_c>

    <windchill_string>NA</windchill_string>

    <windchill_f>NA</windchill_f>

    <windchill_c>NA</windchill_c>

    <feelslike_string>65.7 F (18.7 C)</feelslike_string>

    <feelslike_f>65.7</feelslike_f>

    <feelslike_c>18.7</feelslike_c>

    <visibility_mi>10.0</visibility_mi>

    <visibility_km>16.1</visibility_km>

    <solarradiation/>

    <UV>8</UV>

    <precip_1hr_string>0.00 in ( 0 mm)</precip_1hr_string>

    <precip_1hr_in>0.00</precip_1hr_in>

    <precip_1hr_metric>0</precip_1hr_metric>

    <precip_today_string>in ( mm)</precip_today_string>

    <precip_today_in/>

    <precip_today_metric/>

    <icon>mostlycloudy</icon>

    <icon_url>http://icons.wxug.com/i/c/k/mostlycloudy.gif</icon_url>

    <forecast_url>http://www.wunderground.com/US/GA/Alpharetta.html</forecast_url>

    </current_observation>

    <forecast>...</forecast>

    </response>