<?xml version .....?> <users> <user> <cid>101</cid> <name>poonam</name> </user> </users>
I've written the following code to add a user node , but it's not working. What is wrong with the code?
<html> <head> <script type="text/javascript"> var name,cid; var xmlDoc; function add(form1) { name=form1.name.value; cid=form1.cid.value; loadXML(); }
function loadXML() { xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); xmlDoc.async=false; xmlDoc.load("Users.xml"); parseXML(); }
function parseXML() { var x=xmlDoc.documentElement; alert(x.nodeName+"nodename"); var newNode=xmlDoc.createElement("user"); var newCid=xmlDoc.createElement("cid"); var newName=xmlDoc.createElement("name"); var newcidText=xmlDoc.createTextNode(cid); var newnameText=xmlDoc.createTextNode(name);
I've written the code to add a user node in Users.xml The code is supposed to take the values of "cid" and "name" from the html page and add those to the Users.xml But after execution no node is added to the Users.xml