ASP常用函数:ArrayToxml
程序员文章站
2023-12-04 18:14:58
<% public function arraytoxml(dataarray, recordset, row, x...
<%
public function arraytoxml(dataarray, recordset, row, xmlroot)
dim i, node, rs, j
if xmlroot = "" then xmlroot = "xml"
set arraytoxml = server.createobject("msxml2.freethreadeddomdocument"& msxmlversion)
arraytoxml.appendchild(arraytoxml.createelement(xmlroot))
if row = "" then row = "row"
for i = 0 to ubound(dataarray, 2)
set node = arraytoxml.createnode(1, row, "")
j = 0
for each rs in recordset.fields
node.attributes.setnameditem(arraytoxml.createnode(2, lcase(rs.name), "")).text = dataarray(j, i)& ""
j = j + 1
next
arraytoxml.documentelement.appendchild(node)
next
end function
%>
public function arraytoxml(dataarray, recordset, row, xmlroot)
dim i, node, rs, j
if xmlroot = "" then xmlroot = "xml"
set arraytoxml = server.createobject("msxml2.freethreadeddomdocument"& msxmlversion)
arraytoxml.appendchild(arraytoxml.createelement(xmlroot))
if row = "" then row = "row"
for i = 0 to ubound(dataarray, 2)
set node = arraytoxml.createnode(1, row, "")
j = 0
for each rs in recordset.fields
node.attributes.setnameditem(arraytoxml.createnode(2, lcase(rs.name), "")).text = dataarray(j, i)& ""
j = j + 1
next
arraytoxml.documentelement.appendchild(node)
next
end function
%>
上一篇: ASP常用函数:XMLEncode