Latest web development tutorials

XML DOM substringData () method

Text Object Reference Text objects

Definition and Usage

substringData () method to retrieve data from a text node.

grammar

substringData(start,length)

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


Examples

The following code fragment uses loadXMLDoc () to " the Books.xml " into xmlDoc and get a fragment from the text node first <title> element:

Examples

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"

Text Object Reference Text objects