XML DOM appendData() Method

Definition and Usage

The appendData() method adds a string at the end of the text node.

Syntax:

textNode.appendData(string)
Parameter Description
string Required. The string to be added to the text node.

Example

In all examples, we will use XML files books.xml, and JavaScript functions loadXMLDoc().

The following code snippet appends text to the first <title> element in "books.xml":

xmlDoc=loadXMLDoc("books.xml");
x=xmlDoc.getElementsByTagName("title")[0].childNodes[0];
x.appendData("Cooking");
document.write(x.data);

Output:

Everyday Italian Cooking

Related Pages

XML DOM Reference Manual:CharacterData.appendData()