0

我正在使用 Konfabulator/Yahoo 创建一个 RSS 阅读器小部件。此刻我在

使用拉入 RSS

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

我在这里通过删除错误处理对其进行了简化,但是我还能用什么来使用 konfabulator 完成相同的任务?这是如何跨平台的?

4

1 回答 1

1

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>");
于 2009-12-26T02:20:12.000 回答