开发者

yahoo widgets and importing rss/xml feed using javascript

I'm playing about creating an RSS reader widget using Konfabulator/Yahoo. At the moment I'm

pulling in the RSS using

var xmlDoc = COM.createObject("Microsoft.XMLDOM");
xmlDoc.loadXML("http:foo.com/feed.rss");

I've simplified it here by removing the error handling, but wh开发者_如何学Cat else could I use to do the same task using konfabulator? And how cross platform is this?


COM is Windows-specific, and Yahoo Widgets has XML parsing built-in; so stay away from MSXML :P

You should use the built-in XMLDOM object instead. But since you want to download the XML document from the ’net anyway, XMLHttpRequest supports getting a DOMDocument directly, without having to pass the data to XMLDOM:

var request = new XMLHttpRequest();
request.open( "GET", "http://www.example.com/feed.rss", false);
request.send();
var xmlDoc = request.responseXML;

It works exactly like the XMLHttpRequest on a browser.

For completeness, if you need to parse XML from a string:

var xmlDoc = XMLDOM.parse("<foo>hello world</foo>");
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜