ASP常用函数:ArrayToxml

时间:2022-10-28 22:14:07
  1. <%  
  2. Public Function ArrayToxml(DataArray, Recordset, row, xmlroot)  
  3.     Dim i, node, rs, j  
  4.     If xmlroot = "" Then xmlroot = "xml"  
  5.     Set ArrayToxml = Server.CreateObject("msxml2.FreeThreadedDOMDocument"& MsxmlVersion)  
  6.     ArrayToxml.appendChild(ArrayToxml.createElement(xmlroot))  
  7.     If row = "" Then row = "row"  
  8.     For i = 0 To UBound(DataArray, 2)  
  9.         Set Node = ArrayToxml.createNode(1, row, "")  
  10.         j = 0  
  11.         For Each rs in Recordset.Fields  
  12.             node.Attributes.setNamedItem(ArrayToxml.createNode(2, LCase(rs.Name), "")).text = DataArray(j, i)& ""  
  13.             j = j + 1  
  14.         Next  
  15.         ArrayToxml.documentElement.appendChild(Node)  
  16.     Next  
  17. End Function  
  18. %>