如何向刚创建的node中加入其Attribute??? 急!!!!

keer 2002-03-31 09:53:51
Set objXML = Server.CreateObject("Microsoft.XMLDOM")
objXML.async = false
objXML.load(server.MapPath("*.xml"))

Set objEntry = objXML.createNode("element", "Database", "")
objXML.documentElement.appendChild(objEntry)

Set objEntry = root.createNode("element", "Database", "")
root.documentElement.appendChild(objEntry)
set a2 = root.createAttribute("name")
a2.Value = "dbname"
objEntry.Attributes.Append(a2) '_______此行出错
set a1 = root.createAttribute("when")
a1.Value = Now
objEntry.Attributes.Append(a1)
set a3 = root.createAttribute("intro")
a3.Value = "dbcontext"
objEntry.Attributes.Append(a3)

objXML.save(server.MapPath("*.xml"))


...全文
88 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
keer 2002-03-31
  • 打赏
  • 举报
回复
谢了
karma 2002-03-31
  • 打赏
  • 举报
回复
try to remove the (), the following works for me

set xmldoc = CreateObject("MSXML2.DOMDOCUMENT.3.0")
set node = xmldoc.createElement("root")
node.setAttribute "name","dbname"
xmldoc.appendChild node
keer 2002-03-31
  • 打赏
  • 举报
回复
Microsoft VBScript ҫƷ 펳 error '800a0414'

プӳ̐걲 ĜʹӃ( ż/font>

/xml_db/*.asp, line 36

objEntry.setAttribute("name","dbname")
--------------------------------------^
karma 2002-03-31
  • 打赏
  • 举报
回复
Attributes does not have an Append method

try
objEntry.attributes.setNamedItem(nodePublishDate);

or simple
objEntry.setAttribute("name","dbname")
keer 2002-03-31
  • 打赏
  • 举报
回复
Set objXML = Server.CreateObject("Microsoft.XMLDOM")
objXML.async = false
objXML.load(server.MapPath("*.xml"))

Set objEntry = objXML.createNode("element", "Database", "")
objXML.documentElement.appendChild(objEntry)

set a2 = objEntry.createAttribute("name")
a2.Value = "dbname"
objEntry.Attributes.Append(a2) '_______此行出错
set a1 = objEntry.createAttribute("when")
a1.Value = Now
objEntry.Attributes.Append(a1)
set a3 = objEntry.createAttribute("intro")
a3.Value = "dbcontext"
objEntry.Attributes.Append(a3)

objXML.save(server.MapPath("*.xml"))

为什么错了

8,906

社区成员

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

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