2009知乎:在WEB页面里修改XML文件

来源:百度文库 编辑:神马品牌网 时间:2024/05/02 18:49:10
我的XML文件:
<?xml version="1.0" encoding="gb2312"?>
<aa>
<id>fdasf</id>
</aa>

我在页面里进行如下操作:
<html>
<body>
<script language="javascript">
var xmldoc= new ActiveXObject("Microsoft.xmldom");
xmldoc.async=false;
xmldoc.load("aaa.xml");
var nnode=xmldoc.createNode(1,"id","");
var nnodetext=xmldoc.createNode(3,"text","");
nnodetext.text="guoqi"
xmldoc.documentElement.appendChild(nnode);
xmldoc.documentElement.lastChild.appendChild(nnodetext);
window.alert(xmldoc.xml);
</script>
</body>
</html>

如上操作后window.alert显示都是理想结果,可是XML并没发生任何变化,求高手解答。