public void addCDATA(Document doc) { Element root = doc.getDocumentElement(); Element place = (Element)root.getFirstChild(); Element directions = (Element)place.getLastChild(); String dirtext = ">>>\n" + "<<<\n" + "&&&\n" + "<><><>."; CDATASection dirdata = doc.createCDATASection(dirtext); directions.replaceChild(dirdata,directions.getFirstChild()); }