大虾帮帮忙,帮我看下这个代码,动态生成xml!

casoon 2005-03-21 10:46:15
Dim strFilename,strXMLFile
strFilename = "test.xml"
strXMLFile=server.mapPath(strFilename)
set oXML = server.createObject("Microsoft.XMLDOM")
oXML.async = False
oXML.load(strXMLFile)
oXML.loadXML "<?xml version=""1.0"" encoding=""gb2312"" ?>"
If not bitFileExists Then
set oXMLf=oXML.appendChild(oXML.createElement("Server1"))
set oXMLs2=oXMLf.appendChild(oXML.createElement("Server2"))
End If
for i=0 to 9
set oXMLRec = oXMLs2.appendChild(oXML.createElement("Host"))
Set hostnameAtt = oXML.createAttribute("id")
hostnameAtt.Text = i
oXMLRec.attributes.setNamedItem hostnameAtt
next
oXML.save strXMLFile
oXML = nothing
文件执行成功了,但为什么文件中没有<?xml version="1.0" encoding="gb2312" ?>这个语句,是不是哪里错了!
我想动态更新这个文件要怎么写?
...全文
83 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
casoon 2005-03-21
  • 打赏
  • 举报
回复
谢谢!
ssm1226 2005-03-21
  • 打赏
  • 举报
回复
<%
bitFileExists=true
Dim strFilename,strXMLFile
strFilename = "test.xml"
strXMLFile=server.mapPath(strFilename)
set oXML = server.createObject("Microsoft.XMLDOM")
oXML.async = False
'oXML.load(strXMLFile)
'oXML.loadXML "<?xml version=""1.0"" encoding=""gb2312"" ?>"
If bitFileExists Then
set oXMLf=oXML.appendChild(oXML.createElement("Server1"))
set oXMLs2=oXMLf.appendChild(oXML.createElement("Server2"))
End If
for i=0 to 9
set oXMLRec = oXMLs2.appendChild(oXML.createElement("Host"))
Set hostnameAtt = oXML.createAttribute("id")
hostnameAtt.Text = i
oXMLRec.attributes.setNamedItem hostnameAtt
next

set oProcess=oXML.createProcessingInstruction("xml", "version='1.0' encoding='gb2312'")
oXML.insertBefore oProcess,oXML.childnodes(0)

oXML.save strXMLFile
set oXML = nothing

%>

8,906

社区成员

发帖
与我相关
我的任务
社区描述
XML/XSL相关问题讨论专区
社区管理员
  • XML/XSL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧