dom - How to store data in xml file using javascript? -
i new javascript , using project.in need read xml file , after manipulating want store updated values in xml file.i getting values xml file not able store values xml file. here code have tried.
<html> <head> <title> hello </title> </head> <body> <script> function loadxml() { if (window.xmlhttprequest) {// code ie7+, firefox, chrome, opera, safari xmlhttp=new xmlhttprequest(); } else {// code ie6, ie5 xmlhttp=new activexobject("microsoft.xmlhttp"); } xmlhttp.open("get","data.xml",false); xmlhttp.send(); xmldoc=xmlhttp.responsexml; //saving xml document input fields xmldoc.getelementsbytagname("name")[0].childnodes[0].nodevalue = document.getelementbyid("name").value; xmldoc.getelementsbytagname("address")[0].childnodes[0].nodevalue = document.getelementbyid("address").value; xmldoc.getelementsbytagname("contact")[0].childnodes[0].nodevalue = document.getelementbyid("contact").value; xmldoc.save(); } </script> <form action="display.html" method="post"> <table> <tr> <td>name :</td> <td> <input type="text" id="name"/> </td> </tr> <tr> <td>address :</td> <td> <input type="text" id="address"/> </td> </tr> <tr> <td>contact :</td> <td> <input type="text" id="contact"/> </td> </tr> <tr><td></td><td></td><td><input type="button" value="submit" onclick="loadxml()"></td></tr> </table> </form> </body> </html>
please if knows answer.please explain example if possible in advance...
jquery: use $.ajax()
, send data save_my_xml.php
via post
. there classes work xml in php, if on smarty advise fetch
xml_template.tpl
, file_put_contents
.
Comments
Post a Comment