Load XML File from Client Machine using Javascript
-
-
Hi all, I Develop one application in which i want to load XML file from client machine using javascript and process its nodes. How can i load XML file which is stored at client machine into my application??? :doh: Thanks in advance...
Krishnraj
Javascript does not have the power to to access the file system. you will need to use ActiveX which will read the file for you.
Manas Bhardwaj Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
-
Javascript does not have the power to to access the file system. you will need to use ActiveX which will read the file for you.
Manas Bhardwaj Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
-
Hi manas, First-of-all thanks for reply... Do u have any idea regarding the kind of ActiveX available which read the xml file from client machine as i have a short deadline?? Thanks Again buddy.. :)
Krishnraj
Krishnraj wrote:
Do u have any idea regarding the kind of ActiveX available
var xmlDocument = new ActiveXObject("Msxml2.DOMDocument.3.0");
xmlDocument.load(src);Manas Bhardwaj Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
-
Hi all, I Develop one application in which i want to load XML file from client machine using javascript and process its nodes. How can i load XML file which is stored at client machine into my application??? :doh: Thanks in advance...
Krishnraj
pass the xml string to this function and get the Document object. After that you can call
GetElementsByTagName
to get nodesfunction(text) getXMLDocument {
try {
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = "false";
xmlDoc.loadXML(text);
}
catch (e) {
try {
var parser = new DOMParser();
xmlDoc = parser.parseFromString(text, "text/xml");
}
catch (e) {
alert(e.message);
return;
}
}
return xmlDoc;
}var doc = getXMLDocument('xxgg');
var elements = doc.getElementsByTagName('item');I think this is what you needed. :-D
Abhishek Sur
My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB
**Don't forget to click "Good Answer" if you like to.