我正在尝试使用 Google 的 Feed API 从 DeviantArt 提供的 RSS 提要中获取媒体,以 JSON 格式返回。饲料如下:
http://backend.deviantart.com/rss.xml?type=deviation&q=boost%3Apopular%20tarutaru
谷歌提供了很多例子,但很少涉及媒体提要,而那些这样做的,都使用了媒体组。但是看着我试图阅读的这个特定的提要,我没有看到任何媒体组。每个提要条目只有一个与之关联的“媒体”项目。
<item>
<title>Expectant Tarutaru</title>
<link>http://requiem-shade.deviantart.com/art/Expectant-Tarutaru-38312114</link>
<guid isPermaLink="true">http://requiem-shade.deviantart.com/art/Expectant-Tarutaru-38312114</guid>
<pubDate>Sat, 19 Aug 2006 17:20:08 PDT</pubDate>
<media:title type="plain">Expectant Tarutaru</media:title>
<media:keywords/>
<media:rating>nonadult</media:rating>
<media:category label="Games">fanart/traditional/drawings/games</media:category>
<media:credit role="author" scheme="urn:ebu">Requiem-Shade</media:credit>
<media:credit role="author" scheme="urn:ebu">http://a.deviantart.net/avatars/r/e/requiem-shade.jpg</media:credit>
<media:copyright url="http://requiem-shade.deviantart.com">Copyright 2006-2012 !Requiem-Shade</media:copyright>
<media:description type="html"><![CDATA[ A pregnant Tarutaru White Mage. Was a request from another board. Yes, I took liberties with Square-Enix's original design. Yes, Tarutaru look like that as adults, except the females are flat-chested. Had to augment her form to reflect the development of her body as her children grow inside her. ]]></media:description>
<media:thumbnail url="http://th06.deviantart.net/fs11/150/i/2006/231/c/f/Expectant_Tarutaru_by_Requiem_Shade.jpg" height="150" width="140"/>
<media:thumbnail url="http://th03.deviantart.net/fs11/300W/i/2006/231/c/f/Expectant_Tarutaru_by_Requiem_Shade.jpg" height="322" width="300"/>
<media:content url="http://fc06.deviantart.net/fs11/i/2006/231/c/f/Expectant_Tarutaru_by_Requiem_Shade.jpg" height="463" width="431" medium="image"/>
<media:content url="http://www.deviantart.com/download/38312114/" medium="document"/>
<description><![CDATA[ A pregnant Tarutaru White Mage. Was a request from another board. Yes, I took liberties with Square-Enix's original design. Yes, Tarutaru look like that as adults, except the females are flat-chested. Had to augment her form to reflect the development of her body as her children grow inside her.<br /><div><img src="http://th03.deviantart.net/fs11/300W/i/2006/231/c/f/Expectant_Tarutaru_by_Requiem_Shade.jpg" alt="thumbnail" /></div> ]]></description>
</item>
我现在用来读取提要的代码是这样的,现在只是尝试读取media:title
值,但我想读取所有media:
数据。
/*
* How to load a feed via the Feeds API.
*/
google.load("feeds", "1");
// Our callback function, for when a feed is loaded.
function feedLoaded(result) {
if (!result.error) {
// Grab the container we will put the results into
var container = document.getElementById("content");
container.innerHTML = '';
// Loop through the feeds, putting the titles onto the page.
// Check out the result object for a list of properties returned in each entry.
// http://code.google.com/apis/ajaxfeeds/documentation/reference.html#JSON
for (var i = 0; i < result.feed.entries.length; i++) {
var entry = result.feed.entries[i];
var div = document.createElement("div");
div.appendChild(document.createTextNode(entry.mediaTitle));
container.appendChild(div);
}
}
}
function OnLoad() {
// Create a feed instance that will grab Digg's feed.
var feed = new google.feeds.Feed("http://backend.deviantart.com/rss.xml?type=deviation&q=boost%3Apopular%20tarutaru");
// Calling load sends the request off. It requires a callback function.
feed.load(feedLoaded);
}
google.setOnLoadCallback(OnLoad);
取自此处提供的示例:http ://code.google.com/apis/ajax/playground/#load_feed
问题是,我不知道达到这些值的正确语法是什么,而且我已经尝试了几个小时,所以你现在是我唯一的希望。
任何帮助将不胜感激。这是我为我兄弟做的生日礼物,我想尽快摆脱这种麻烦,以便送出礼物。:)
先感谢您。