0
我试图从网页上的rss文档中删除节点。无法从Javascript删除文档中的一组节点
我想从去:
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title></title>
<link></link>
<description></description>
<item>
<title>53w5</title>
<link>est</link>
<description></description>
</item>
</channel>
</rss>
要:
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title></title>
<link></link>
<description></description>
</channel>
</rss>
这只是删除的项目(和他的所有子)。
这是我的函数加载XML:
function loadXMLDoc(dname) {
if (window.XMLHttpRequest) {
xhttp = new XMLHttpRequest();
}
else {
xhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xhttp.open("GET", dname, false);
xhttp.send("");
return xhttp.responseXML;
}
这是我已经删除了块代码:
xmlDoc = loadXMLDoc("rssFeed.xml");
it = xmlDoc.getElementsByTagName("item");
it.parentNode.removeChild(it);
我总是他们的错误“遗漏的类型错误:无法调用方法在Chrome中运行时,会出现“undefined”的removeChild。我的XML文件加载完毕,因为我可以在网络中看到它在resquest之后。
帮助将不胜感激。
安东尼
谢谢主席先生,我想作为一个以前的解决方案由我有一个语法错误类似的东西。 – AdnMonkeys 2013-02-28 19:53:40