大家看看这段asp

oneway 2002-12-20 09:23:22
为什么生成的xml只有<?xml version="1.0" encoding="GB2312"?>


<!--#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 * FROM basic"
RS.Open SQL,Conn,1,1
RS.MoveFirst

Dim xmldoc
Set xmldoc = server.CreateObject("Msxml2.DOMDocument.4.0")

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

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

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

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

%>
...全文
67 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
sunmingdong 2002-12-20
  • 打赏
  • 举报
回复
给你一个简单的例子:
Dim a
Set a= server.CreateObject("Microsoft.XMLDOM")
Dim element
a.loadXML "<ROOT/>" ''loadXML方法,load一个xml字符串
a.documentElement.setAttribute "id", "00001" ''填写根节点属性id='00001'
Set element = a.createElement("Record") ''定义一个element变量
element.setAttribute "name", "yourname" ''增加element的属性name='yourname'
element.Text = "context" ''增加element的内容context
a.documentElement.appendChild element ''把element加到a.documentElement(根节点)的下面
response.write a.xml ''用字符串形式输出a
ChinaOk 2002-12-20
  • 打赏
  • 举报
回复
Http://www.w3schools.com
xmldom的学习指南。

Http://www.ChinaOK.net/Examples/
js+xml+dom的一些例子。

你可以下一个xmlsdk看看。
saucer 2002-12-20
  • 打赏
  • 举报
回复
1. replace "CreateNode" with "CreateElement"

2. remove or comment out this line:
on error resume next

8,906

社区成员

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

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