Inserting an Entity Reference Using createEntityReference
To insert such characters as an entity references, use Document.createEntityReference rather than createTextNode. This example produces the same result as the previous example, but uses a character entity to insert the u-umlaut:
var doc = Application.activeDocument;
var paras = doc.getElementsByTagName("para");
var newText1 = doc.createTextNode("Austrians are known for their Gem");
var charEnt = doc.createEntityReference("uuml");
var newText2 = doc.createTextNode("tlichkeit");
paras.item(0).appendChild(newText1);
paras.item(0).appendChild(charEnt);
paras.item(0).appendChild(newText2);