[jdom-interest] unexpected getText() results

David Kavanagh dak at dotech.com
Mon Jul 22 07:48:48 PDT 2002

I'm new to JDOM, but have been using XML with Java for well over 3 years.
I'm seeing something that puzzles me. Given a document like the following...

<String>this is a line of text<br/>and another line of text</String>

I call getContent() on the <String> element. I would expect to get a 
List containing (Text, Element, Text) objects.
I seem to get this, but to assemble my string, I first call getText() on 
the first Text object. I get the string "this is a line of test". Then I 
get the name of the Element to verify it is a <br>, then add a "\n" into 
my result string. Then, I call getText() on the last Text object. I 
would expect to get "and another line of text", but I don't. I get "this 
is a line of textand another line of text". What's happening here? I'm 
going to look over the source code...


More information about the jdom-interest mailing list