News:

This week IPhone 15 Pro winner is karn
You can be too a winner! Become the top poster of the week and win valuable prizes.  More details are You are not allowed to view links. Register or Login 

Main Menu

Getting XML From a Database

Started by ben2ong2, October 06, 2006, 03:55:05 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ben2ong2

XML can be generated from a database without any installed XML software.
To generate an XML database response from the server, simply write the following code and save it as an ASP file on the web server:
<%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>")%>
You are not allowed to view links. Register or Login
You are not allowed to view links. Register or Login