简体   繁体   English

使用Firefox XML DOM解析XML(RSS)

[英]Using Firefox XML DOM to parse XML(RSS)

Any example on how to parse/have access to simple RSS feed elements in JS? 关于如何解析/可以访问JS中的简单RSS feed元素的任何示例吗? I don't want to use any Microsoft specific objects. 我不想使用任何Microsoft特定的对象。

If you have XML in a string, you can parse it using the following in Firefox: 如果字符串中包含XML,则可以在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. 如果您从XMLHttpRequest XML,则请求的responseXML属性将是对XML文档的引用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM