XML DOM » CharacterData » appendData

Syntax:
characterData.appendData(data)
data
Receives the string that will be appended to the existing string data.

This method appends the specified string to existing string data.

Examples

Code:
XML:

<capitals>
   <capital>Beijing</capital>
   <capital>Berlin</capital>
   <capital>London</capital>
   <capital>Paris</capital>
   <capital>Washington</capital>
</capitals>

JavaScript:

xml_doc = new ActiveXObject("Microsoft.XMLDOM");
xml_doc.async = false;
xml_doc.load("capitals.xml");

text = xml_doc.documentElement.lastChild.firstChild;
text.appendData(" DC");
document.write(text.data);
Output:
Washington DC
Explanation:

In this example using the 'capitals.xml' file, the code appends the characters ' DC' to the text of the last 'capital' element (Washington).

Language(s): JavaScript XML