|
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.
Recent Original Stories (OS News) "One of the things my team has been working to enable has been the ability for .NET developers to download and browse the source code of the .NET Framework libraries, and to easily enable debugging support in them. Related Articles (New Mobile Computing) Apress' open source series of books recently unveiled Mark Mamone's " Practical Mono ", a book targetting new .NET developers. We take a quick look at the book below.
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
|
|