Sample code using XML and ASP

We will see how we can access data in an xml file using asp. To do this first you have to create an xmldom object as given in the code below:

Dim xmlobj
Set xmlobj=Server.CreateObject("Microsoft.XMLDOM")

After creating this xmldom object you will be working with the xmlobj to load the xml file into it. For this you have to use the xmldom object's Load method as given below:

mydoc.load("path_to_the_xml_file")

You should know that the Load method takes only the physical path to the xml file and most of the time it is difficult to hardcode the physical path of that file. Hence you can use the Server.

MapPath method to get the physical path to the xml file. Before you use the load method set the async property of the xmldom object to false.

Now you can trap the error code that is generated by the xmldom object upon using the Load method. If the error code is not zero, it means that there is some error in loading and you can write the routine to handle the errors. If the error code is zero then you have loaded the xml file properly and you can do whatever you want.

Now navigate through the xmlobj using documentElement.childNodes and display the data in the asp file.



SetApp - 100 Apps for everything you ever wanted to do on Mac

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

 

 

“Amazon and the Amazon logo are trademarks of Amazon.com, Inc. or its affiliates.”

Copyright - © 2004 - 2019 - All Rights Reserved.