0

Hello!

I am working on updation of an old asp classic website. I have experience in Asp.net but dont know much about asp classic. I want to show my query results in xml format. I am getting data in my record set but unable to convert it into xml and also dont know how to show xml on the page.
I need help in this.

Regards.

2
Contributors
2
Replies
10
Views
3 Years
Discussion Span
Last Post by JorgeM
0

An easy way to generate an XML response is to build it manually...Its much easier to use methods() in asp.net but in classic ASP, this is fairly easy to do.

For example..

<%
response.ContentType="text/xml"
response.Write("<?xml version='1.0' encoding='UTF-8'?>")
response.Write("<book>")
response.Write("<author>Jim Smith</author>")
response.Write("<title>Best Book</tile>")
response.Write("<description>Great book to read.</description>")
response.Write("</book>")
%>
0

If you are going to incorporate the results from your database query...

    <%
    response.ContentType = "text/xml"
    set conn=Server.CreateObject("ADODB.Connection")
    conn.provider="Microsoft.Jet.OLEDB.4.0;"
    conn.open server.mappath("database.mdb")

    sql="select author,title, description from books"
    set rs=Conn.Execute(sql)

    response.write("<?xml version='1.0' encoding='UTF-8'?>")
    response.write("<book>")
    while (not rs.EOF)
    response.write("<author>" & rs("author") & "</author>")
    response.write("<title>" & rs("title") & "</title>")
    response.write("<description>" & rs("description") & "</description>")
    rs.MoveNext()
    wend

    rs.close()
    conn.close()
    response.write("</book>")
    %>

This code is not tested... just meant to give you an example...

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.