Click here to Skip to main content
16,021,181 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i want to save updated data in xml using Javascript.

below is my code, not saving xml file.

JavaScript
if (window.XMLHttpRequest) {
           xhttp = new XMLHttpRequest();
       }
       else // code for IE5 and IE6
       {
           xhttp = new ActiveXObject("Microsoft.XMLHTTP");
       }

       xhttp.open("GET", "books.xml",false);
       xhttp.setRequestHeader("Accept", "text/xml");
       xhttp.send();
       xmlDoc = xhttp.responseXML;
       x = xmlDoc.getElementsByTagName("title")[0].childNodes[0];

       x.nodeValue = "Easy Cooking";
       xmlDoc.Save("books.xml");
Posted
Updated 5-May-15 18:58pm
v3
Comments
Sergey Alexandrovich Kryukov 6-May-15 1:00am    
How can anyone help a person doing such dirty things as using ActiveXObject in browser? Perhaps you did not realize that, but if some safety-savvy users find out that you do it, it would be enough to blacklist your site. Other people won't use browsers supporting it.
—SA

1 solution

I am affraid you cannot write files with pure js.
Earlier internet explorer alloved this kinda action by activex object but for security matters its not possible you should use node.js to handle files with javascript
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900