Latest web development tutorials

XML DOM length property

NamedNodeMap Object Reference NamedNodeMap objects

Definition and Usage

NamedNodeMap length property returns the number of nodes.

grammar

nodemapObject.length

Examples

The following code fragment uses loadXMLDoc () to " the Books.xml " into xmlDoc and obtain the number of the first <book> element attributes:

Examples

xmlDoc=loadXMLDoc("books.xml");

x=xmlDoc.getElementsByTagName('book');

document.write(x.item(0).attributes.length);

The code above will output:

1

try it"

Try Demos

length - Returns the number of nodes in the node list

length - loop through the nodes in the node list


NamedNodeMap Object Reference NamedNodeMap objects