急!在xml文件中怎样添加这类节点?在线等待。。。
xml文件格式如下:
<?xml version="1.0" encoding="UTF-8"?>
<config>
<form>
<formRecord id="1"/>
<formRecord id="2"/>
<formRecord id="3"/>
</form>
<global>
<globalRecord id="1"/>
<globalRecord id="2"/>
<globalRecord id="3"/>
</global>
</config>
该文件已经存在现在我需要将xml文件添加为以下格式:既内容"<formRecord id="4"/>"和"<formRecord id="4"/>"为增加的节点.这类节点怎样增加,多谢帮助!
<?xml version="1.0" encoding="UTF-8"?>
<config>
<form>
<formRecord id="1"/>
<formRecord id="2"/>
<formRecord id="3"/>
<formRecord id="4"/>
</form>
<global>
<globalRecord id="1"/>
<globalRecord id="2"/>
<globalRecord id="3"/>
<globalRecord id="4"/>
</global>
</config>
问题点数:0、回复次数:2Top
1 楼net_lover(【孟子E章】)回复于 2005-06-03 15:03:52 得分 0
Set xmldom = Server.CreateObject("Msxml2.DOMDocument")
xmldom.async=false
xmldom.load Server.MapPath("xx.xml")
Set n1 = xmldom.createNode("formRecord")
Set n2 = xmldom.createAttribute("id")
n2.value="4"
n1.setNamedItem n2
Set node = xmldom.selectSingleNode("//form")
node.appendChild n1Top
2 楼net_lover(【孟子E章】)回复于 2005-06-03 15:10:48 得分 0
<%
Set xmldom = Server.CreateObject("Msxml2.DOMDocument")
xmldom.async=false
xmldom.load Server.MapPath("x.xml")
Set n1 = xmldom.createElement("formRecord")
n1.setAttribute "id","4"
Set node = xmldom.selectSingleNode("//form")
node.appendChild n1
Set n1 = xmldom.createElement("globalRecord")
n1.setAttribute "id","4"
Set node = xmldom.selectSingleNode("//global")
node.appendChild n1
xmldom.save Server.MapPath("x.xml")
%>Top




