我正在使用 RSS Feeds 和 WinJS 为 Windows 8 创建一个 9GAG 阅读器应用程序。
代码:
function downloadBlogFeed() {
WinJS.xhr({ url: "http://feeds.feedburner.com/9GAG" }).then(function (rss) {
var items = rss.responseXML.querySelectorAll("item");
for (var n = 0; n < items.length; n++) {
var article = {};
article.title = items[n].querySelector("title").textContent;
var thumbs = items[n].querySelectorAll("thumbnail");
if (thumbs.length > 1) {
article.thumbnail = thumbs[1].attributes.getNamedItem("url").textContent;
article.content = items[n].textContent;
articlesList.push(article);
}
}
});
}
问题是我无法从 FeedBurner 获得 9GAG Feed。我收到此错误:
Can't load http://feeds.feedburner.com/~d/styles/itemcontent.css. An app can’t load remote web content in the local context.
我也试过改变
WinJS.xhr({ url: "http://feeds.feedburner.com/9GAG" })
和
WinJS.xhr({ url: "http://9gag.com/?feed=rss" })
但我收到此错误:
Exception is about to be caught by JavaScript library code at line 50, column 13 in ms-appx://7df7a30e-2f19-4f36-b368-c456fde8aabd/js/default.js
0x800a138f - JavaScript runtime error: Unable to get property 'querySelectorAll' of undefined or null reference
File: default.js
它指向这一行:
var items = rss.responseXML.querySelectorAll("item");
你能帮我,做对吗?
谢谢 !