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,

aspxmlobj.GetParent2()

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.




_______________________________________________

FREE Subscription

Subscribe to our mailing list and receive new articles
through email. Keep yourself updated with latest
developments in the industry.

Name:
Email:

Note : We never rent, trade, or sell my email lists to
anyone. We assure that your privacy is respected
and protected.

_______________________________________





 

 

FREE Subscription

Stay Current With the Latest Technology Developments Realted to XML. Signup for Our Newsletter and Receive New Articles Through Email.

Name:

Email:

Note : We never rent, trade, or sell our email lists to anyone. We assure that your privacy is respected and protected.

 

 

Add to My Yahoo!

Visit XML Training Material Guide Homepage

 

 

Copyright - © 2004 - 2017 - All Rights Reserved.