Monday, September 8, 2008

How to load XML file with Physical Path using Java Script

Hi friends,

I faced one problem while developing an application which interact with XML file. A HTML page will load a XML file and process that for building a Tree Type Structure.

We can easily load a Context file which is at our Context Root Path using...

xmlObject.loadXML("filename.xml");

but while we need to load XML file from physical path like D: , E: or any drive and folder than how can we do that ?

Ans: We can use file protocol for same like if our XML file is at D:\Shirin\file1.xml than we can access that same file using following line:

xmlObject.loadXML("file:///D:/Shirin/file1.xml");

make sure to use forwarding slash and after file: use 3 continues ///

Thanks




Contributors