Latest web development tutorials

XML DOM length property

NodeList Object Reference NodeList objects

Definition and Usage

length property returns the number of nodes in the node list.

grammar

nodelistObject.length

Examples

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

Examples

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 Demos

length - loop through the nodes in the node list


NodeList Object Reference NodeList objects