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.

Recommended Answers

All 2 Replies

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>")
%>

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...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.