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

Per Norrman per.norrman at austers.se
Tue Sep 13 08:33:33 PDT 2005


root.setText("test1\ntest2");


Kevin Chiu skrev:
> 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);
> 
> _______________________________________________
> To control your jdom-interest membership:
> http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com
> 
> 



More information about the jdom-interest mailing list