XML DOM lengthProperty


Text object

Definition and Usage

The length property returns the text length of the node (in characters).

Syntax

textNode.length

Example

The following code snippet usesloadXMLDoc()put "books.xmlLoad into xmlDoc, and output the text node data and length of the first <title> element:

Example

xmlDoc=loadXMLDoc("books.xml");
x=xmlDoc.getElementsByTagName("title")[0].childNodes[0];

document.write(x.data);
document.write(" - Length: ");
document.write(x.length);

The code above will output:

Everyday Italian - Length: 16

Try it Yourself »

Text objectother extensions