Dave
Dave

Reputation: 4328

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 what else could I use to do the same task using konfabulator? And how cross platform is this?

Upvotes: 0

Views: 472

Answers (1)

Nicolás
Nicolás

Reputation: 7523

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>");

Upvotes: 1

Related Questions