XML DOM insertData()Methods


CDATA object

Definition and Usage

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

Syntax

insertData(start,string)

Parameter Description
start Required. Specifies where to begin inserting characters. The start value begins at 0.
string Required. Specifies the data to be inserted.


Example

The following code snippet usesloadXMLDoc()put "books_cdata.xml" Load into xmlDoc, and insert data into the CDATA node of the first <html> 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 Yourself »

CDATA objectother extensions