XML DOM insertData()Methods
Text object
Definition and Usage
insertData() method inserts data into a text node.
Syntax
insertData(start,string)
| Parameter | Description |
|---|---|
| start | Required. Specifies where to start inserting characters. The start value begins at 0. |
| string | Required. Specifies the string to be inserted. |
Example
The following code snippet usesloadXMLDoc()put "books.xmlLoad into xmlDoc, and insert a string into the text node of the first <title> element:
Example
xmlDoc=loadXMLDoc("books.xml");
x=xmlDoc.getElementsByTagName("title")[0].childNodes[0];
x.insertData(0,"Cooking: ");
document.write(x.data);
x=xmlDoc.getElementsByTagName("title")[0].childNodes[0];
x.insertData(0,"Cooking: ");
document.write(x.data);
Output:
Cooking: Everyday Italian
Try it Yourself »
Text objectother extensions