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;

image

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");

image

 

and also we can change it by nodeValue property too…

enjoy DOM and XML play.. Smile

0

Add a comment

I am
I am
Archives
Total Pageviews
Total Pageviews
2 0 5 7 7 0 6
Categories
Categories
Loading