I'm trying to access the georss:point data from a feed using the feed
api, and it's not working. Here's what I'm doing:
google.load("feeds", "1");
function initialize()
{
var feed = new google.feeds.Feed("http://audioboo.fm/users/30904/tags/
60-uksm.atom");
feed.setNumEntries(50);
feed.includeHistoricalEntries();
feed.setResultFormat(google.feeds.Feed.XML_FORMAT);
feed.load( function(result)
{
var container = document.getElementById("feed");
var georssNS = "http://www.georss.org/georss";
var itunesNS = "http://www.itunes.com/dtds/podcast-1.0.dtd"
if (!result.error)
{
var items =
result.xmlDocument.getElementsByTagName("entry");
for (var i = 0; i < items.length; i++)
{
var titleElement =
items[i].getElementsByTagName("title")[0];
var title = titleElement.firstChild.nodeValue;
var summaryElement =
items[i].getElementsByTagName("summary")[0];
var summary =
summaryElement.firstChild.nodeValue;
var placeElement =
google.feeds.getElementsByTagNameNS(items[i],
georssNS, "point")[0];
var place = placeElement.firstChild.nodeValue;
alert(place);
var authorElement =
google.feeds.getElementsByTagNameNS(items[i],
itunesNS, "author")[0];
var author = authorElement.firstChild.nodeValue;
var durationElement =
google.feeds.getElementsByTagNameNS(items[i], itunesNS, "duration")
[0];
var duration =
durationElement.firstChild.nodeValue;
var div = document.createElement("div");
div.innerHTML = title + "<br />" + summary +
"<br />" + author +
"<br />" + duration + "<br /><br />";
// div.appendChild(document.createTextNode(title +
"<br />" +
summary));
container.appendChild(div);
}
}
} );
}
google.setOnLoadCallback(initialize);
If I try this as is, the page breaks and I get a message in the error
console saying "placeElement is undefined." If I comment out these
lines
[var placeElement =
google.feeds.getElementsByTagNameNS(items[i], georssNS, "point")[0];
var place = placeElement.firstChild.nodeValue;
alert(place);]
it works--although then I get an error saying "authorElement is
undefined." (But the page still loads, and the author gets displayed.)
Any suggestions?
--
You received this message because you are subscribed to the Google
Groups "Google AJAX APIs" group.
To post to this group, send email to
[email protected]
To unsubscribe from this group, send email to
[email protected]
To view this message on the web, visit
http://groups.google.com/group/google-ajax-search-api?hl=en_US
For more options, visit this group at
http://groups.google.com/group/google-ajax-search-api?hl=en?hl=en