Java DOM edit: Replacing a Text Node with a New CDATASection Node : DOM Edit « XML « Java
- Java
- XML
- DOM Edit
Java DOM edit: Replacing a Text Node with a New CDATASection Node
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());
}
Related examples in the same category