Latest web development tutorials

XML DOM substringData () method

CDATA Object Reference CDATA objects

Definition and Usage

substringData () method to get a string from the CDATA node.

grammar

CDATANode.substringData(start,length)

参数 描述
start 必需。规定从何处开始提取字符。开始值以 0 开始。
length 必需。规定提取多少字符。


Examples

The following code fragment uses loadXMLDoc () to " books_cdata.xml " into xmlDoc and get "Stun" string from the first element of a CDATA:

Examples

xmlDoc=loadXMLDoc("books_cdata.xml");

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

y=x.substringData(3,4);

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

Output:

Stunning!
Stun

try it"

CDATA Object Reference CDATA objects