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


CDATA Object Reference CDATA Object


Definition and Usage

The insertData() method inserts data into a CDATA 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 data to insert.

Example

The following code snippet uses loadXMLDoc() to load "books_cdata.xml" Load into xmlDoc, and insert data into the CDATA node of the first element:

Example

xmlDoc=loadXMLDoc("books_cdata.xml");

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

x.insertData(3,"Wonderful and ");

document.write(x.data);

Output:

Wonderful and Stunning!

Try it »


CDATA Object Reference CDATA Object