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


CDATA Object Reference CDATA Object


Definition and Usage

The length property returns the number of characters in the selected node.

Syntax

CDATANode.length


Example

The following code snippet uses loadXMLDoc() to load "books_cdata.xml" Load into xmlDoc, and from the first get the text node data and length of an element: </p>

Example

xmlDoc=loadXMLDoc("books_cdata.xml");

x=xmlDoc.getElementsByTagName("html")[0].childNodes[0];

document.write(x.data);

document.write(" - Length: ");

document.write(x.length);

The code above will output:

Stunning!

Try it »

Please remember that the length above is the length of the entire CDATA section (Stunning!), not just the length of the text.


CDATA Object Reference CDATA Object