Search code examples
javascriptajaxxmllatitude-longitudeyahoo-weather-api

How to access the text within yahoo weather's geo data nodes?


I'm using the z weatherfeed plugin.

It already pulls most of the data from yweather api but I need the latitude and longitude.

The plugin gets the data for each item element like this for example:

html += '<div class="weatherCountry">'+ feed.location.country +'</div>';

However, if I try this...

html += '<div class="latitude">' + feed.item.geo.lat + '</div>';
html += '<div class="longitude">' + feed.item.geo.long + '</div>';

...it doesn't get the data for these elements.

How should I go about accessing both the geo:lat and geo:long?

Here's a live example: http://jsbin.com/sibafeke/1/edit


Solution

  • The data for geo:lat and geo:long can be accessed this way:

    html += '<div class="latitude">' + feed.item.lat + '</div>';
    html += '<div class="longitude">' + feed.item.long + '</div>';