Create an XML File From a Database (1)
XML can be generated by using server-side scripts. For example, you can select
data from your database, and use the data to generate an XML file. The following
is an example of how to use ASP to create an XML file:
<%
response.ContentType = "text/xml"
set conn=Server.CreateObject("ADODB.Connection")
conn.provider="Microsoft.Jet.OLEDB.4.0;"
conn.open server.mappath("mydb.mdb")
sql="select * from customers"
set rs=Conn.Execute(sql)
response.write("<?xml version='1.0' encoding='ISO-8859-1'?>")
response.write("<customerlist>")
while (not rs.EOF)
response.write("<customer>")
response.write("<firstname>" & rs("firstname")
& "</firstname>")
response.write("<lastname>" & rs("lastname") &
"</lastname>")
response.write("<address>" & rs("address") &
"</address>")
response.write("<city>" & rs("city") & "</city>")
response.write("<state>" & rs("city") & "</state>")
response.write("<zip>" & rs("zip") & "</zip>")
response.write("<email>" & rs("email") &
"</email>")
response.write("<phone>" & rs("phone") &
"</phone>")
response.write("</customer>")
rs.MoveNext()
wend
rs.close()
conn.close()
response.write("</customerlist>")
%>
|