Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

XML DOM length Property

XML DOM length Property


NodeList Object Reference NodeList object


Definition and Usage

The length property returns the number of nodes in a NodeList.

Syntax

nodelistObject.length


Example

The following code snippet uses loadXMLDoc() to load "books.xml" Load into xmlDoc, and get the number of elements: </p>

Example

xmlDoc=loadXMLDoc("books.xml");

x=xmlDoc.getElementsByTagName('title');

document.write("Number of title elements: " + x.length);

The code above will output:

Number of title elements: 4

Try it »


Try it Demos

length - Loop through the nodes in a NodeList


NodeList Object Reference NodeList object