xml| Generate xml| Data | database
<%
Set Xmldoc=server.createobject ("MSXML2. DOMDocument ")
Set Obj=server.createobject ("Gdcom.database")
Set Rs=server.createobject ("Adodb.recordset")
Set fso = CreateObject ("Scripting.FileSystemObject")
Xmldoc.async=false
XmlDoc. Validateonparse=false
Str= "Select Code,pyt,detail from zdb where kind= ' 92 '"
Set Rs=obj.runsqlreturnrs (str)
Set AddFile = fso. CreateTextFile (Server.MapPath (".") & "\20060801.xml", True)
Set root = Xmldoc.createnode (1, "book", "Record")
Set temp = xmldoc.appendchild (root)
Set objnodeattr = xmldoc. CreateAttribute ("AJBH")
Objnodeattr.value = "A2107270006002004080001"
XmlDoc. Documentelement.setattributenode (objnodeattr)
Set ajlx= Xmldoc.createnode ("element", "Ma", "")
Set temp = root.appendchild (AJLX)
Set ajlb= Xmldoc.createnode ("element", "La", "")
Set temp = ajlx.appendchild (AJLB)
if not Rs. EOF Then
Rs. MoveFirst
while (not Rs. EOF)
Set onode = Xmldoc.createnode ("element", "rec", "")
Set temp = ajlb.appendchild (onode)
for i = 0 to Rs. Fields.count-1
Set child = Xmldoc.createnode ("element", Rs. Fields (i). Name, "")
If not IsNull (Rs. Fields (i)) Then
Child. Text = Rs. Fields (i)
Else
Child. Text = ""
end If
Set temp = Onode.appendchild (Child)
Next
Rs. MoveNext
Wend
Rstoxml = Root.xml
Else
Rstoxml = ""
End If
AddFile. WriteLine (Rstoxml)
Addfile.close
Set fso=nothing
Response.Write ("ok!")
%>