asp用dom创建xml的问题

oneway 2002-12-18 04:55:24
大家看看这段asp,为什么不能生成指定文件?

<!--#include file="GetDB.inc"-->
<%
on error resume next
Dim SQL,RS

Set RS = Server.CreateObject("ADODB.RecordSet")
Set conn = server.createobject("adodb.connection")
OpenDBConn conn

SQL = "SELECT name,age,sex FROM basic WHERE id=2"
RS.Open SQL,Conn,1,1
RS.MoveFirst

Dim xmldoc
Set xmldoc = server.CreateObject("Microsoft.XMLDOM")

Dim version
Set version = xmldoc.createProcessingInstruction("xml","version='1.0' encoding='GB2312'")
xmldoc.appendchild(version)

Dim root
Set root = xmldoc.CreateNode("element","root","students")
xmldoc.appendChild(root)

while (Not RS.EOF)
Set childNode = xmldoc.CreateNode("element","student",root.appendChild(childNode))
For Each f in rs.Fields
Set childnextNode = xmldoc.CreateNode("elements",f.name,"")
childnextNode.Text = f.Value
childNode.appendChild(childnextNode)
Next
RS.MoveNext
wend

xmldoc.save(Server.Mappath("info.xml"))

%>

...全文
71 1 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
ssm1226 2002-12-18
  • 打赏
  • 举报
回复
<%
on error resume next
Dim SQL,RS

Set RS = Server.CreateObject("ADODB.RecordSet")
Set conn = server.createobject("adodb.connection")
OpenDBConn conn

SQL = "SELECT name,age,sex FROM basic WHERE id=2"
RS.Open SQL,Conn,1,1
RS.MoveFirst

Dim xmldoc
Set xmldoc = server.CreateObject("Msxml2.domdocument")

Dim version
Set version = xmldoc.createProcessingInstruction("xml","version='1.0' encoding='GB2312'")
xmldoc.appendchild(version)

Dim root
Set root = xmldoc.createElement("root")
xmldoc.appendChild(root)


while Not RS.EOF
Set childNode = xmldoc.createElement("student")
For Each f in rs.Fields
Set childnextNode = xmldoc.createElement(f.name)
childnextNode.Text = f.Value
childNode.appendChild(childnextNode)
Next
RS.MoveNext
root.appendChild childNode
wend

xmldoc.save(Server.Mappath("info.xml"))

%>

8,907

社区成员

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

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