The XMLHttpRequest Object and Database Usage Save Data to an XML File First we will learn how to create and save an XML file. The XML file below will be named "test.xml" and will be stored in the c directory on the server. We will use ASP and Microsoft's XMLDOM object to create and save the XML file: <% dim xmlDoc, rootEl, child1, child2, p 'create an XML document set xmlDoc = Server.CreateObject("Microsoft.XMLDOM") 'xmlDoc.preserveWhiteSpace=true 'create a root element and append it to the document set rootEl = xmlDoc.createElement("root") xmlDoc.appendChild rootEl 'create and append child elements set child1 = xmlDoc.createElement("child1") set child2 = xmlDoc.createElement("child2") rootEl.appendChild child1 rootEl.appendChild child2 'other commands, not used 'set attID = xmlDoc.createAttribute("id") 'attID.Text = Request.Form.Key(i) 'child1.setAttributeNode attID 'higherel.appendChild lowerel 'add an XML processing instruction and insert it before the root element set p=xmlDoc.createProcessingInstruction("xml","version='1.0'") xmlDoc.insertBefore p,xmlDoc.childNodes(0) 'save the XML file to the c directory xmlDoc.Save "c:\test.xml" %> test.xml: <?xml version="1.0"?> <root> <child1 /> <child2 /> </root> -------------------------------------------------------------------------------- http://www.w3schools.com/ado/default.asp <% response.ContentType = "text/xml" set conn=Server.CreateObject("ADODB.Connection") conn.provider="Microsoft.Jet.OLEDB.4.0;" conn.open server.mappath("/db/database.mdb") sql="select fname,lname from tblGuestBook" set rs=Conn.Execute(sql)rs.MoveFirst()response.write("<?xml version='1.0' encoding='ISO-8859-1'?>") response.write("<guestbook>") while (not rs.EOF) response.write("<guest>") response.write("<fname>" & rs("fname") & "</fname>") response.write("<lname>" & rs("lname") & "</lname>") response.write("</guest>") rs.MoveNext() wendrs.close() conn.close() response.write("</guestbook>") %>