Latest web development tutorials

XML DOM nodeName property

Attr Object Reference Attr objects

Definition and Usage

nodeName property returns the name of the node, depending on its type.

grammar

attrObject.nodeName


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"

Try Demos

Display Properties nodeName, nodeValue, and nodeType


Attr Object Reference Attr objects