http://www.eggheadcafe.com/articles/20010209.asp
<%
dim moADOCon
dim moADORec
dim msADOConStr
' Your database connection string.
msADOConStr = Application("sDBConn")
Sub ReturnXML()
dim sXML
dim sXMLType
' Your system's object for indicating content type (if applicable).
Response.ContentType="text/xml"
' Your system's object to handle query strings.
sXMLType = Trim(Request.QueryString("XMLREQUEST"))
Select Case sXMLType
Case "0" ' Return back straight XML.
' Use your database tool or business logic to
' create an XML stream. Then write your XML
' stream output just as you would sending it
' to the browser. In ASP, it would look like this:
sXML = sXML & "<?xml version='1.0'?>"
sXML = sXML & "<VENDORS>"
sXML = sXML & " <VENDOR>"
sXML = sXML & " <ID>1</ID>"
sXML = sXML & " <LNAME>Company 1</LNAME>"
sXML = sXML & " </VENDOR>"
sXML = sXML & " <VENDOR>"
sXML = sXML & " <ID>2</ID>"
sXML = sXML & " <LNAME>Company 2</LNAME>"
sXML = sXML & " </VENDOR>"
sXML = sXML & "</VENDORS>
Response.write sXML
Case "1" ' Return back XML formatted specifically for ADO
Set moADOCon = Server.CreateObject("ADODB.Connection")
Set moADORec = Server.CreateObject("ADODB.Recordset")
moADOCon.open msADOConStr
Set moADORec.ActiveConnection = moADOCon
' ADO supports writing directly to the ASP Response
' object from the ADO recordset.
moADORec.Open "Your SQL Statement Goes Here"
moADORec.Save Response,adPersistXML
On Error Resume Next
If moADORec.STATE = adStateOpen Then moADORec.Close
If moADOCon.STATE = adStateOpen Then moADOCon.Close
Set moADORec = Nothing
Set moADOCon = Nothing
Case Else
' Your system's object for output to the browser
' (our server A).
Response.write "XMLERR " & "0"
end select
end sub
Call ReturnXML()
%>
<%
dim moADOCon
dim moADORec
dim msADOConStr
' Your database connection string.
msADOConStr = Application("sDBConn")
Sub ReturnXML()
dim sXML
dim sXMLType
' Your system's object for indicating content type (if applicable).
Response.ContentType="text/xml"
' Your system's object to handle query strings.
sXMLType = Trim(Request.QueryString("XMLREQUEST"))
Select Case sXMLType
Case "0" ' Return back straight XML.
' Use your database tool or business logic to
' create an XML stream. Then write your XML
' stream output just as you would sending it
' to the browser. In ASP, it would look like this:
sXML = sXML & "<?xml version='1.0'?>"
sXML = sXML & "<VENDORS>"
sXML = sXML & " <VENDOR>"
sXML = sXML & " <ID>1</ID>"
sXML = sXML & " <LNAME>Company 1</LNAME>"
sXML = sXML & " </VENDOR>"
sXML = sXML & " <VENDOR>"
sXML = sXML & " <ID>2</ID>"
sXML = sXML & " <LNAME>Company 2</LNAME>"
sXML = sXML & " </VENDOR>"
sXML = sXML & "</VENDORS>
Response.write sXML
Case "1" ' Return back XML formatted specifically for ADO
Set moADOCon = Server.CreateObject("ADODB.Connection")
Set moADORec = Server.CreateObject("ADODB.Recordset")
moADOCon.open msADOConStr
Set moADORec.ActiveConnection = moADOCon
' ADO supports writing directly to the ASP Response
' object from the ADO recordset.
moADORec.Open "Your SQL Statement Goes Here"
moADORec.Save Response,adPersistXML
On Error Resume Next
If moADORec.STATE = adStateOpen Then moADORec.Close
If moADOCon.STATE = adStateOpen Then moADOCon.Close
Set moADORec = Nothing
Set moADOCon = Nothing
Case Else
' Your system's object for output to the browser
' (our server A).
Response.write "XMLERR " & "0"
end select
end sub
Call ReturnXML()
%>