<% '# this script writes an xml file containing UserID,Username and Email of all users # '-- get records from db -- Dim zobjRS,zobjRS1,zstrSQL zstrSQL = "SELECT userInfo.UserID, userInfo.Username, userInfo.Email FROM userInfo ORDER BY userInfo.UserID" Set zobjRS1 = Server.CreateObject("ADODB.Recordset") zobjRS1.Open zstrSQL, zobjConn, adOpenForwardOnly, adLockReadOnly, adCmdText zobjRS = zobjRS1.GetRows() '-- close down rs -- zobjRS1.Close Set zobjRS1 = Nothing zobjConn.Close Set zobjConn = Nothing '-- write xml -- Dim zobjXML Set zobjXML = Server.CreateObject("Microsoft.XMLDOM") 'Set zobjXML = Server.CreateObject("Msxml2.XMLDocument") 'msxml v3 zobjXML.appendChild(zobjXML.createProcessingInstruction("xml","version=""1.0""")) 'xml declaration zobjXML.appendChild(zobjXML.createElement("users")) 'root Dim zobjXML1,zobjXML2 '-- create the user node -- Set zobjXML1 = zobjXML.createElement("user") 'create zobjXML1.appendChild(zobjXML.createElement("username")) zobjXML1.appendChild(zobjXML.createElement("email")) Set zobjXML2 = zobjXML1.cloneNode(True) 'save this empty node setup in memory '-- insert values into node -- Dim i,zLimit zLimit = UBound(zobjRS,2) For i = 0 to zLimit '# zobjXML1 is always a new, clean node. thanks to saving the node earlier, and resetting at the end of the loop zobjXML1.setAttribute "userid",zobjRS(0,i) zobjXML1.childNodes(0).text = zobjRS(1,i) 'insert values zobjXML1.childNodes(1).text = zobjRS(2,i) zobjXML.documentElement.appendChild(zobjXML1.cloneNode(True)) 'add this node to the xml document Set zobjXML1 = zobjXML2 'set zobjXML1 to the clean node saved earlier Next zobjXML.Save(Server.MapPath("../kaos/generated/users.html")) 'save the now fully written xml to a file on the server 'zobjXML.Save("c:\sites\kaos\users.xml") '-- close down -- Set zobjXML = Nothing Set zobjXML1 = Nothing Set zobjXML2 = Nothing %>