MSXML向文件中添加节点

 我来答
xuehuaze
2009-03-01 · 超过18用户采纳过TA的回答
知道答主
回答量:44
采纳率:0%
帮助的人:47.9万
展开全部
<?xml version="1.0"?>
<BBS>
<topic topicId="0">
<title>this web site is good</title>
<time> 2005-09-08 08:00:00</time>
<ip>221.106.82.*</ip>
<body>when I was young</body>
<nickname>Anonymous</nickname>
<replies>
<reply replyID="0">
<title>this web site is good</title>
<time> 2005-09-08 08:00:00</time>
<ip>221.106.82.*</ip>
<body>when I was young</body>
<nickname>Anonymous</nickname>
</reply>
<reply replyId="1">
<title>111</title>
<time>09-13-2005 11:37:25GMT</time>
<ip>127.0.0.*</ip>
<body>1111</body>
<nickname>111</nickname>
</reply>
</replies>
</topic>
<topic topicId="1">
<title>this web site look good</title>
<time> 2005-09-08 06:00:00</time>
<ip>66.106.82.*</ip>
<body>luck off product</body>
<nickname>Anonymous</nickname>
</topic>
</BBS>
以上是XML文件
以下是ASP
<%

Set objNode = objXML.getElementsByTagName("BBS/topic/replies")
Set objNode = objNode.Item(0)

Set replyInfoNode = objXML.createNode("element", "reply", "")
Set replyInfoNode = objNode.appendChild(replyInfoNode)

Set replyIdInfo = objXML.createAttribute("replyId")
replyIdInfo.Text = replyID
replyInfoNode.Attributes.setNamedItem (replyIdInfo)

Set replyIdNode = objXML.createNode("element", "title", "")
replyIdNode.Text = title
Set replyIdNode = replyInfoNode.appendChild(replyIdNode)

Set replyIdNode = objXML.createNode("element", "time", "")
replyIdNode.Text = content_time
Set replyIdNode = replyInfoNode.appendChild(replyIdNode)

Set replyIdNode = objXML.createNode("element", "ip", "")
replyIdNode.Text = ip
Set replyIdNode = replyInfoNode.appendChild(replyIdNode)

Set replyIdNode = objXML.createNode("element", "body", "")
replyIdNode.Text = content
Set replyIdNode = replyInfoNode.appendChild(replyIdNode)

Set replyIdNode = objXML.createNode("element", "nickname", "")
replyIdNode.Text = nickname
Set replyIdNode = replyInfoNode.appendChild(replyIdNode)

objXML.save (Server.MapPath("bbs.xml"))
response.redirect "showlist.asp"
%>
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式