Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

XML DOM insertData() Method

XML DOM insertData() Method


Text Object Reference Text Object


Definition and Usage

The insertData() method inserts data into a text node.

Syntax

insertData(start,string)

Parameters Description
start Required. Specifies where to start inserting characters. The starting value begins at 0.
string Required. Specifies the string to insert.

Example

The following code snippet uses loadXMLDoc() to load "books.xml" Load into xmlDoc, and to the first a string into the text node of an element: </p>

Example

xmlDoc=loadXMLDoc("books.xml");

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

x.insertData(0,"Cooking: ");

document.write(x.data);

Output:

Cooking: Everyday Italian

Try it »


Text Object Reference Text Object