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.
Note
: We never rent, trade, or sell my email lists to
anyone.
We assure that your privacy is respected
and protected.
_______________________________________
Recommended
XML Books
|
|