How to generate XML using ASP
Creating an xml file is a breeze using asp. To start with you have to set the ContentType of the document to text/xml in your code. The next step is to create an AspXml object. This can be done using the following code:
set aspxmlobj = Server.CreateObject("AspXml.AspXml")
Now you can create the root node with the code,
aspxmlobj.Tag = "name_of_root_node"
To start creating the first record, you can use the command,
set aspxmlobj = xml.NewChild("name_of_the_record", "")
Now to add the child elements to the new record, you can use,
aspxmlobj.NewChild2 "name_of_the_child", "value_of_the_child"
You can use the above command and keep on adding the additional child elements to the record. Now if you want to add another record you can do so by navigating to the parent node using,
and start again with aspxmlobj.NewChild.
This way you can create all the records needed for the xml document use the aspxmlobj.GetXml() method to get the xml document created to be displayed. You can use the Response.Write method to display the xml document thus created.
Copyright - © 2004 - 2017 - All Rights Reserved.