Skip to content

Generating XML with ASP

January 8, 2007
<%
response.ContentType="text/xml"
response.Write("<?xml version='1.0' encoding='ISO-8859-1'?>")
response.Write("<note>")
response.Write("<from>Jani</from>")
response.Write("<to>Tove</to>")
response.Write("<message>Remember me this weekend</message>")
response.Write("</note>")
%>
Getting XML From a Database
<%
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>")
%>

		
No comments yet

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: