简体   繁体   English

我想使用JavaScript访问和修改XML文件。 修改后,我需要保存它。 请帮忙!

[英]I want to access and modify XML file using JavaScript. After modifying it I need to save it. Please help!

Here is the xml file I want to modify - 这是我要修改的xml文件-

Note: Sorry somehow I cannot type '<' 注意:很抱歉,我无法输入'<'

<nsml version="-//iNEWS//DTD NSML 2.0//EN">

<head> meta wire=o words=347 rate=175> rgroup number=214> wgroup number=214>

<fields>

<f id=title> Title /f>

<f id=headline> Headline /f>

<f id=summary >Summary /f>

</fields>

Here is my JavaScript code - 这是我的JavaScript代码-

 var xmlHttp=null;

 try {

   // Firefox, Opera 8.0+, Safari

   xmlHttp=new xmlHttpRequest();

 }

 catch(e) {

   // Internet Explorer

   try {

         xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");

    }

    catch (e) {

        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");

    }

 }

 xmlHttp.open("GET","test.xml",false);

 xmlHttp.send();

 xmlDoc=xmlHttp.responseXML; 

 x=xmlDoc.getElementsByTagName("f")[0].childNodes[0]; /*says x is null or not an object */

 x.nodeValue="New Title";

Thanks for your help! 谢谢你的帮助!

You can't modify files only with javascript. 您不能仅使用javascript修改文件。 Even if you can... why would you do it? 即使可以...为什么要这么做?

暂无
暂无

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

相关问题 我是 JavaScript 的新手。 请帮我进行 javascript 验证 - I am new to JavaScript. please help me for javascript validation PHP和JavaScript中的变量。 我需要基本了解方面的帮助。 - Variables in php and JavaScript. I need help on basic understanding. 我想使用Jquery或Javascript检索XML节点。 节点包含表单的HTML - I want to retrive XML node using Jquery or Javascript. Node contains HTML of a form 我无法通过用户使用 html 和 javascript 输入给定日期来找到以前的日期。 你能帮帮我吗 - I'm unable to find a previous date by inputing a given date by a user using html and javascript. Can you please help me out 我有一个从 CSV 转换为 JavaScript 的 HTML 表。我想向第二列中的行添加超链接。 请帮我 - I have a HTML table converted from CSV with JavaScript. I want to add hyperlinks to the rows in the 2nd column. Please help me 使用javascript创建和修改xml文件(想在客户端保存xml文件) - create and modify xml file using javascript (want to save xml file on client side) 无法用JavaScript替换文本。 请帮忙 - Trouble replacing text with JavaScript. Please help 我想创建一个按钮,仅使用 HTML、css 和 JavaScript 将用户计算机中的音乐文件加载到 div。 那可能吗? - I want to create a button that will load a music file from the users computer to a div using just HTML, css, and JavaScript. Is that possible? 我需要帮助来设置此JavaScript代码 - I need help setting up this JavaScript code please 我想用 JavaScript 创建一个自动计数器。 我有一些代码,但我不能在某个数字上停止,任何人都可以帮我这个 - I want to create an automatic counter in JavaScript. I have code something but I cannot stop that at a certain number can anyone help me this
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM