使用Javascript保存xml [英] Save xml using Javascript

查看:62
本文介绍了使用Javascript保存xml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Javascript在xml中保存更新的数据。



以下是我的代码,不保存xml文件。



i want to save updated data in xml using Javascript.

below is my code, not saving xml file.

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");

推荐答案

我很害怕你不能用纯粹的js写文件。

早期的互联网资源管理器为activex对象提供了这种行动,但是对于安全问题你不应该使用node.js来处理javascript文件
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


这篇关于使用Javascript保存xml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆