简体   繁体   English

更改XML文件中的XML属性值

[英]Changing the XML attribute value in XML file

This is my XML file. 这是我的XML文件。

<ops>
<emp>
    <name>asd</name>
    <ntid>123</ntid>
    <pwd>123</pwd>
    <score></score>
</emp>
<emp>
    <name>bvrtb</name>
    <ntid>1341</ntid>
    <pwd>1341</pwd>
    <score></score>
</emp>
</ops>

I have this script with which i'm able to change the pwd with a new password. 我有这个脚本,可以使用新密码更改密码。

var x = xmlDoc.getElementsByTagName('pwd');
x[i].setAttribute("pwd", document.getElementById("newpassword").value);

With this the value is getting changed but when i refresh the page again the same old value is loaded. 有了这个值被改变,但当我再次刷新页面时,相同的旧值被加载。 How can i change this pwd value in the XML file.. 如何更改XML文件中的该pwd值。

Thanks in advance. 提前致谢。

JavaScript is executed in a client browser and your code is operating on data "copy" returned by server. JavaScript在客户端浏览器中执行,并且您的代码在服务器返回的数据“副本”上运行。 If you want to change XML you have to do it on server-side. 如果要更改XML,则必须在服务器端进行。 Every time you are requesting XML it is loaded from server resources, not reachable by client JS code. 每次请求XML时,它都是从服务器资源加载的,客户端JS代码无法访问。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM