Capt. Horatio T.P. Webb
Sending XML from the Server
Parks -- FALL 2000

To send XML from the server to the client we only need to notify the client that the data being sent is XMl. To accomplish this we first use:

response.ContentType="text/xml"

This notifies the client that the data is to be interpreted as XML not HTML (the default content type). Once the content type is established we need only send the XML data in the response. This can be done by creating a string of XML by any of the techniques discussed on the Receiving and Creating XML page (i.e., building a XML string with logic; reading the XML from a file; or rolling through the XMLDOM to generate the string). The entire asp program is:

 
<%
response.contentType="text/xml"
xmldata="<toptag><first>1</first><second>2</second><third>3</third></toptag>"
response.write xmldata
%>
 

Click here to see it work. Note this example employs IE5's XML processing capability to display the XML data.