Add/update nodes in xml file using javascript
-
Hi I want to Add/update nodes in xml file using javascript..... is it possible? if yes then HOW.... Thanks
Dinesh Sharma
-
Hi I want to Add/update nodes in xml file using javascript..... is it possible? if yes then HOW.... Thanks
Dinesh Sharma
hi yes it's possible. i tell you that if you use asp.net it's better to use it's features for manipulating XML docs. using this function you can load a xml file in your HTML document. //javascript function code for loading XML doc function loadXMLDoc(dname) { var xmlDoc // code for IE if (window.ActiveXObject) { xmlDoc=new ActiveXObject("Microsoft.XMLDOM") } // code for Mozilla, Firefox, Opera, etc. else if (document.implementation && document.implementation.createDocument) { xmlDoc=document.implementation.createDocument("","",null) } else { alert('Your browser cannot handle this script'+'
Reason: Your browser does not support XML document') } xmlDoc.async=false try { xmlDoc.load(dname) } catch(err) { alert("When loading XML document one error occured\nError: "+err) return(null) } return(xmlDoc) } after loading XML doc you can use XML DOM for manipulating. for more information about XML DOM visit http://www.w3schools.com/dom/default.asp bye. Mohammad Khansari -
hi yes it's possible. i tell you that if you use asp.net it's better to use it's features for manipulating XML docs. using this function you can load a xml file in your HTML document. //javascript function code for loading XML doc function loadXMLDoc(dname) { var xmlDoc // code for IE if (window.ActiveXObject) { xmlDoc=new ActiveXObject("Microsoft.XMLDOM") } // code for Mozilla, Firefox, Opera, etc. else if (document.implementation && document.implementation.createDocument) { xmlDoc=document.implementation.createDocument("","",null) } else { alert('Your browser cannot handle this script'+'
Reason: Your browser does not support XML document') } xmlDoc.async=false try { xmlDoc.load(dname) } catch(err) { alert("When loading XML document one error occured\nError: "+err) return(null) } return(xmlDoc) } after loading XML doc you can use XML DOM for manipulating. for more information about XML DOM visit http://www.w3schools.com/dom/default.asp bye. Mohammad KhansariThanks for your reply I have already implemented the script and I am getting the updated string....but its not updating my physical file "XMLFile.xml". How can I update the file..... Thanks
Dinesh Sharma
-
Thanks for your reply I have already implemented the script and I am getting the updated string....but its not updating my physical file "XMLFile.xml". How can I update the file..... Thanks
Dinesh Sharma
hi using javascript code you can manipulate XML doc in client computer not server computer if you want to manipulate XML doc on server computer you must use a server side programing javascript is a client-side programing language. do you use ASP.NET? I don't know where is your XML doc? in Client computer or server computer. plz answer this question.
Mohammad Khansari
-
hi using javascript code you can manipulate XML doc in client computer not server computer if you want to manipulate XML doc on server computer you must use a server side programing javascript is a client-side programing language. do you use ASP.NET? I don't know where is your XML doc? in Client computer or server computer. plz answer this question.
Mohammad Khansari
my file is on server and m using asp.net 2.0... actually if i am using serverside code then page reloads so i am trying to use [Ajax.AjaxMethod()] but it doesn't work properly..... is there any other way...like ajax or.....
Dinesh Sharma
-
my file is on server and m using asp.net 2.0... actually if i am using serverside code then page reloads so i am trying to use [Ajax.AjaxMethod()] but it doesn't work properly..... is there any other way...like ajax or.....
Dinesh Sharma
hi If you explain more then I can help you. do you want to change a xml doc exists on server through client? bye.
Mohammad Khansari