Programmer's Guide > Programming and Scripting Techniques > Basic Document Manipulation Using the DOM and AOM > Inserting Text > Inserting Text Using createTextNode
  
Inserting Text Using createTextNode
This example appends the line “Adding new text.” to the end of the first paragraph in a document
var doc = Application.activeDocument;
var paras = doc.getElementsByTagName("para");
//create the new Text Node
var newText = doc.createTextNode(" Adding new text.");
//append it to first paragraph
paras.item(0).appendChild(newText);