In the DOM, everything is a node. Element nodes do not have a text value.
The text of an element node is stored in a child node. This node is called a text node.
Change the Value of a Text Node
eg:
to=xmlDoc.getElementsByTagName("to")[0].childNodes[0];
to.nodeValue=madhuka@gmail.com;
Change the Value of an Attribute
In the DOM, attributes are nodes. Unlike element nodes, attribute nodes have text values.
I am using the setAttribute() method for it
x=xmlDoc.getElementsByTagName('email');
x[0].setAttribute("eid","e0");
x[1].setAttribute("eid","e1");
and also we can change it by nodeValue property too…
enjoy DOM and XML play..
Add a comment