永发信息网

如何对xml添加子节点,我的总是被覆盖了,请高手指点

答案:2  悬赏:0  手机版
解决时间 2021-01-29 11:26
  • 提问者网友:伴风望海
  • 2021-01-28 13:39
代码如下,用vbs写的
Set xmlFile =CreateObject("Msxml2.DOMDocument")
xmlFile.async=False
xmlFile.load(Server.MapPath("myxml.xml"))
'测试文件是否存在,不存在则创建
if xmlFile.parseError.ErrorCode<>0 then
Set oPI=xmlFile.createProcessingInstruction("xml", "version=""1.0"" encoding=""GB2312""")
xmlFile.insertBefore oPI,xmlFile.childNodes(0)
set roots=xmlFile.createElement("root")
xmlFile.appendChild(roots)
else
set roots=xmlFile.documentElement
end if
Set oNode=xmlFile.createElement("Item")
set cn=xmlFile.createElement("cn")
oNode.appendChild(cn)

roots.insertBefore oNode, null
xmlFile.save(Server.MapPath("myxml.xml"))

我想添加多个相同的 Item 子节点,可以这样做吗?还是要添加属性来区分
每次运行时都会把之前添加的子节点覆盖了,想了很 久还是不懂,大家帮帮忙啊!!!
最佳答案
  • 五星知识达人网友:掌灯师
  • 2021-01-28 15:12
看了好久。。。。。我也不懂了。
好麻烦。
顶起你的帖子,希望有更多的人能看到,更多的人能回答
全部回答
  • 1楼网友:逃夭
  • 2021-01-28 16:16
documenthelper 里面的代码如何写的,看看
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯