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