XML DOM lengthProperty


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 usesloadXMLDoc()put "books_cdata.xmlLoad into xmlDoc, and get the text node data and length from the first <title> element:

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 above code will output:

Stunning! - Length: 16

Try it Yourself »

Remember that the length above is the length of the entire CDATA section (<b>Stunning!</b>), not just the length of the text.


CDATA objectother extensions