XML DOM length attribute
Definition and usage
The length attribute can return the number of nodes in the NamedNodeMap.
Syntax
nodemapObject.length
Instance
In all examples, we will use the XML file books.xml, and JavaScript functions 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