请问如何删除XML的一个节点(用JavaScript应该如何实现)
<?xml version="1.0" encoding="GB2312"?>
<UrlLib>
<Group Name="聊天">
<Url Channels="聊天" Name="网易聊天" Link="http://chat.163.com/index.html"/>
<Url Channels="聊天" Name="碧海银沙聊天" Link="http://chat.yinsha.com/"/>
<Url Channels="聊天" Name="新浪聊天" Link="http://newchat.sina.com.cn/"/>
<Url Channels="聊天" Name="263聊天" Link="http://chat.263.net/"/>
<Url Channels="聊天" Name="Tom聊天室" Link="http://chat.tom.com/chat/"/>
<!--Url Channels="聊天" Name="上海热线聊天" Link="http://newchat.online.sh.cn/"/-->
<Url Channels="聊天" Name="QQ聊天室" Link="http://chat.qq.com/"/>
<!--Url Channels="聊天" Name="中国名人聊天室" Link="http://www.kpworld.com/celebrity/chat/"/-->
</Group>
<Group Name="游戏">
<Url Channels="游戏" Name="新浪游戏" Link="http://games.sina.com.cn/"/>
<Url Channels="游戏" Name="联众游戏" Link="http://www.ourgame.com/"/>
<Url Channels="游戏" Name="网易游戏" Link="http://game.163.com/"/>
<Url Channels="游戏" Name="泡泡堂" Link="http://www.poptang.com/"/>
<Url Channels="游戏" Name="GameSpot" Link="http://www.gamespot.com.cn/"/>
<Url Channels="游戏" Name="传奇3" Link="http://www.mir3.com.cn/"/>
<Url Channels="游戏" Name="17173" Link="http://www.17173.com/"/>
</Group>
</UrlLib>
我要删除<Url Channels="聊天" Name="碧海银沙聊天" Link="http://chat.yinsha.com/"/>
这个节点,请问用JavaScript应该如何实现
问题点数:20、回复次数:4Top
1 楼dotnetbus(程序爬虫)回复于 2004-12-03 12:01:07 得分 0
removeChildTop
2 楼dotnetbus(程序爬虫)回复于 2004-12-03 12:28:45 得分 20
<script language="javascript">
var xmldoc = new ActiveXObject("Msxml2.DomDocument");
xmldoc.async = false;
xmldoc.load("test.xml");
chatnodes = xmldoc.selectSingleNode("//Url[@Channels='聊天' and @Name='碧海银沙聊天']");
nodeset = xmldoc.selectNodes("//Group[@Name='聊天']");
nodeset.item(0).removeChild(chatnodes);
alert(xmldoc.xml);
</script> Top
3 楼chenyt_ren(冷冰雨)回复于 2004-12-03 14:25:13 得分 0
谢谢了Top
4 楼chenyt_ren(冷冰雨)回复于 2004-12-03 14:27:04 得分 0
问一下,nodeset.item(0).removeChild(chatnodes);为什么需要 item(0) 啊? nodeset.removeChild(chatnodes);不行吗?
Top




