XML DOM substringData()Methods


Text object

Definition and Usage

The substringData() method retrieves data from a text node.

Syntax

substringData(start,length)

Parameter Description
start Required. Specifies where to start extracting characters. The start value begins at 0.
length Required. Specifies how many characters to extract.


Example

The following code snippet usesloadXMLDoc()put "books.xmlLoad into xmlDoc, and retrieve a fragment from the text node of the first <title> element:

Example

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

y=x.substringData(9,7);

document.write(x.nodeValue);
document.write("
");
document.write(y);

Output:

Everyday Italian
Italian

Try it Yourself »

Text objectother extensions