Using Firefox XML DOM to parse XML(RSS)
Any example on how to parse/have access to simple RSS feed elements in JS? I don't want to 开发者_运维百科use any Microsoft specific objects.
If you have XML in a string, you can parse it using the following in Firefox:
var xmlStr = "<test>Hello world</test>";
var parser = new DOMParser();
var xmlDoc = parser.parseFromString(xmlStr, "text/xml");
alert(xmlDoc.documentElement.nodeName);
If you've got your XML from an XMLHttpRequest
, the responseXML
property of the request will be a reference to an XML document.
精彩评论