How ASP can return XML


In this article, I will explain how ASP can return XML. XML can be generated on a server without any installed XML software. To generate an XML response from the server write the following code and save it as an ASP file on the web server. Note: the content type of the response must be set to "text/xml". Learn How ASP can return XML

Overview on How ASP can return XML


How ASP can return XML code:

XML file on server

<?xml version="1.0" encoding="ISO-8859-1"?>
<message>
<from>Raj</from>
<to>Sam</to>
<msg>Hello</msg>
</message>


Generating XML with ASP:

<%
response.ContentType="text/xml"
response.Write("")
response.Write("")
response.Write("Raj")
response.Write("Sam")
response.Write("Hello")
response.Write("")
%>




Note :the content type of the response must be set to "text/xml".


Saving XML To a File Using ASP


<%
text=""
text=text & "Raj"
text=text & "Sam"
text=text & "Hello!"
text=text & "
"

set xmlDoc=Server.CreateObject("Microsoft.XMLDOM")
xmlDoc.async="false"
xmlDoc.loadXML(text)

xmlDoc.Save("raj.xml")
%>


Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: