开发者

Parsing mixed result from google feed api

开发者 https://www.devze.com 2023-02-28 15:30 出处:网络
Can someone give me example how to parse mixed feed result from google api (eg. XML + json). I\'m trying to get enclosure element of the feed, but it seems that json resul开发者_如何学运维t doesn\'t r

Can someone give me example how to parse mixed feed result from google api (eg. XML + json). I'm trying to get enclosure element of the feed, but it seems that json resul开发者_如何学运维t doesn't return it! Thanks!


To get feeds in mixed mode you have to set results mode to MIXED_FORMAT. all entries should now include a xmlNode from which the enclosure element can be retrieved, and the url extracted:

var feed = new google.feeds.Feed(feedUrl);
feed.setResultFormat(google.feeds.Feed.MIXED_FORMAT);
feed.load( function(result) {
   var entry = result.feed.entries[i];
   var entryImageUrl = entry.xmlNode.getElementsByTagName("enclosure")[0].getAttribute("url");
});
0

精彩评论

暂无评论...
验证码 换一张
取 消