[jdom-interest] question from a newbie

bob mcwhirter bob at werken.com
Sat Nov 4 14:24:51 PST 2000

> I read data from a HTML Form (for example, a comment of users in a textarea
> field) via servlets and I stored it in a DB, when the user wants to check
> his comments, I get from DB, create a XML Doc and transform it using a XSL
> file, then display it in HTML, here everything is OK!!, but... I want to
> convert every new line character in the comment to a <br> HTML tag in order
> to preserve new lines in HTML format... how can I do that??

Well, um, a <br> tag by itself isn't valid XML, so you can't really
do that with JDOM.

I might possibly break up the text based on newlines into conceptual
paragraphs, create a new Element("p"), and set the text to be the
paragraph, and then add that back to your tree.

If you really only want textual substitution of \n-><br> and
you don't want to use JDOM, then maybe jakarta-regexp is what you
need (http://jakarta.apache.org/).


More information about the jdom-interest mailing list