开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜