Latest web development tutorials

XML DOM nodeValue property

Attr Object Reference Attr objects

Definition and Usage

nodeValue property sets or returns the value of a node, depending on its type.

grammar

attrObject.nodeValue


Examples

The following code fragment uses loadXMLDoc () to " the Books.xml " into xmlDoc and displays the node name category attribute node values, and node types:

Examples

xmlDoc=loadXMLDoc("books.xml");
x=xmlDoc.getElementsByTagName('book');
for(i=0;i<x.length;i++)
{
document.write(x.item(i).attributes[0].nodeName);
document.write(" = ");
document.write(x.item(i).attributes[0].nodeValue);
document.write(" (nodetype: ");
document.write(x.item(i).attributes[0].nodeType + ")");
document.write("
");
}

Output:

category = COOKING (nodetype: 2)
category = CHILDREN (nodetype: 2)
category = WEB (nodetype: 2)
category = WEB (nodetype: 2)

try it"

Attr Object Reference Attr objects