0
我使用GoogleFeed API(https://developers.google.com/feed/)來檢索RSS源使用此代碼:GoogleFeed檢索圖像
function loadAuto(){
google.load("feeds", "1");
function initialize() {
var feed = new google.feeds.Feed("http://www.automoto.sk/rss");
feed.setNumEntries(window.localStorage.getItem("entriesNumber"));
feed.load(function(result) {
if (!result.error) {
var feedlist = document.getElementById("feedAuto");
for (var i = 0; i < result.feed.entries.length; i++) {
var li = document.createElement("li");
var entry = result.feed.entries[i];
var A = document.createElement("A");
var descriptionSettings = window.localStorage.getItem("descriptionSettings");
if (descriptionSettings=="true"){
var h3 = document.createElement("h3");
var p = document.createElement("p");
var pDate = document.createElement("p");
pDate.setAttribute("style","text-align: right; margin-top: 5px;");
var publishedDate = new Date(entry.publishedDate);
publishedDateConverted = convertTime(publishedDate);
pDate.appendChild(document.createTextNode(publishedDateConverted));
h3.setAttribute("style","white-space: normal;")
h3.appendChild(document.createTextNode(entry.title));
p.setAttribute("style","white-space: normal;")
p.appendChild(document.createTextNode(entry.content));
A.setAttribute("href",entry.link);
A.appendChild(h3);
A.appendChild(p);
A.appendChild(pDate);
}
else{
A.setAttribute("href",entry.link);
A.appendChild(document.createTextNode(entry.title));
};
li.appendChild(A);
feedlist.appendChild(li);
}
$("#feedAuto").listview("refresh");
}
});
}
google.setOnLoadCallback(initialize);
};
一切工作正常,但我不能負擔一個elemenet。這是RSS結構:
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>automoto.sk</title>
<link>http://www.automoto.sk</link>
<description>automoto.sk</description>
<language>sk</language>
<image><title>automoto.sk</title><url>http://img.automoto.sk</url><link>http: //www.automoto.sk</link></image>
<pubDate>Thu, 13 Sep 2012 12:22:45 +0200</pubDate>
<item>
<title><![CDATA[Nová Kia pro_ceed: Najdynamickejší Slovák]]></title>
<link>http://www.automoto.sk/clanok/188988/nova-kia-pro-ceed-najdynamickejsi-slovak</link>
<pubDate>Thu, 13 Sep 2012 09:22:00 +0200</pubDate>
<guid isPermaLink="false">5e14ddbf095fe497eaf03f9a8cd88773</guid>
<description><![CDATA[PARÍŽ 2012 Trojdverový variant druhej generácie typu cee’d má podstatne štipľavejší dizajn ako jeho praktickejší brat.]]></description>
<enclosure url="http://img.automoto.sk/img/20/title/1395542-img-nova-kia-pro-ceed.jpg" length="0" type="image/jpeg"></enclosure>
</item>
</rss>
我需要加載位於機櫃中的img,但我不知道如何加載機櫃url變量。也許可以將格式改爲XML。我已經嘗試將其更改爲XML,但我無法使其工作。因此,如果您知道如何以JSON格式加載圖像,或者如果您知道如何轉換initialize()函數,以便使用XML並加載img URL,請發佈您的建議。
PS:,你可以在這個網站http://www.automoto.sk/rss/