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 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.
|
|
||
|
|||
“Amazon and the Amazon logo are trademarks of Amazon.com, Inc. or its affiliates.”
Copyright - © 2004 - 2019 - All Rights Reserved.