Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » JDOM User »

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

Per Norrman

2005-07-14

Replies:


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@(protected)
>
>

_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@(protected)
©2008 junlu.com - Jax Systems, LLC, U.S.A.