[jdom-interest] The correct way to insert newlines and other text codes into JDOM elements

Kevin Chiu kevin.gc+jdom at gmail.com
Mon Sep 12 01:37:41 PDT 2005


Hello,

What's the correct way to add newlines (or other special characters)
to the text of a JDom element?
This is how I'm doing it now:

Element root = new Element("ROOT");
Text newline = new Text("");
Text content1 = new Text("");
Text content2 = new Text("");

content1.setText("test1");
newline.setText("\n"); //This seems kind of hackish
content2.setText("test2");

root.addContent(content1);
root.addContent(newline);
root.addContent(content2);



More information about the jdom-interest mailing list