XML DOM length attribute

NamedNodeMap object reference manual

Definition and usage

The length property can return the number of nodes in the NamedNodeMap.

Syntax

nodemapObject.length

Example

In all examples, we will use the XML file books.xml, as well as the JavaScript function loadXMLDoc().

The following code snippet can obtain the number of attributes in the first <book> element of the XML document:

xmlDoc=loadXMLDoc("books.xml");
var x=xmlDoc.getElementsByTagName('book');
document.write(x.item(0).attributes.length);

Output:

1

NamedNodeMap object reference manual