XML With javascript
-
hi, While appending a node,whether it will affect original file or not below is my code <html> <body> <script type="text/javascript"> if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.open("GET","x.xml",false); xmlhttp.send(); xmlDoc=xmlhttp.responseXML; x=xmlDoc.getElementsByTagName("CD"); for (i=0;i<x[0].childNodes.length;i++) { if (x[0].childNodes[i].nodeType==1) { document.write(x[0].childNodes[i].nodeName); document.write(": "); document.write(x[0].childNodes[i].childNodes[0].nodeValue); document.write("<br />"); } } document.write('<br>-----------------<br>'); for(i=0;i<x.length;i++) { newel=xmlDoc.createElement("PUBLICATION"); newtext=xmlDoc.createTextNode("2007"); newel.appendChild(newtext); x[i].appendChild(newel); } for(i=0;i<x.length;i++) { for (j=0;j<x[i].childNodes.length;j++) { if (x[i].childNodes[j].nodeType==1) { document.write(x[i].childNodes[j].nodeName); document.write(": "); document.write(x[i].childNodes[j].childNodes[0].nodeValue); document.write("<br />"); } } document.write("<br />"); } alert </script> </body> </html> Regards