<!DOCTYPE html> <html> <head> <script type="text/javascript"> function addElement() { var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.4.0"); var root; var newNode; xmlDoc.async = false; xmlDoc.resolveExternals = false; xmlDoc.load("user.xml"); try { root = xmlDoc.documentElement; alert(root.xml); var n1 =document.getElementById("t1").value; var p1 =document.getElementById("t2").value; newNode = xmlDoc.createElement("user"); var name =xmlDoc.createNode(1, "name", n1); var pass = xmlDoc.createNode(1, "pass", p1); newNode.appendChild(name); newNode.appendChild(pass); root.appendChild(newNode); alert(root.xml); xmlDoc.save("user.xml"); document.WriteString(root.lastChild.nodeValue); alert("added"); } catch(e) { alert("error"); } } </script> </head> <body> <form id="user_form" method="post"> <table> <tr> <td>Name :</td><td><input type="text" id="t1"></td> </tr> <tr> <td>Password :</td><td><input type="text" id ="t2"></td> </tr> <tr> <td><input type ="Submit" id="b1" önclick="addElement()"></td> </tr> </table> </form> </body> </html>
xmlDoc.DocumentElement.AppendChild(newNode); xmlDoc.save("user.xml");
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)