开发者

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

开发者 https://www.devze.com 2023-02-06 06:30 出处:网络
Here is the xml fi开发者_JS百科le I want to modify - Note: Sorry somehow I cannot type \'<\' <nsml version=\"-//iNEWS//DTD NSML 2.0//EN\">

Here is the xml fi开发者_JS百科le I want to modify -

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 -

 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. Even if you can... why would you do it?

0

精彩评论

暂无评论...
验证码 换一张
取 消