[jdom-interest] When a text contains HTML-tagged info...

Masaki Itagaki mitagaki at uswest.net
Mon Dec 18 22:59:36 PST 2000


Thank you for your info, Jason.

>I think more likely it returns "This is a  text!"  If it returns what
>you claim, then it's a bug.  <b> is a child of <a> and doesn't have its
>text included.  (Hey, no one said holding HTML in XML was easy.)

I tried the same thing with Beta 5, but it did the same. When an element
goes...

<segment>This is a <bpt i="1" type="bold" />test<ept i="1" />
sentence.</segment>

Then, when I extract text with getText as follows:

Element segment = ((Element)obj).getChild("segment");
String sentence = segment.getText();

Then "sentence" contains [This is a test sentence] instead of [This is a
sentence]. I was thinking that getText returens all the String contents of
an element (not just of itself, butg also of all the one-level children) ,
so I didn't think it was a bug. Or am I missing something?

>Look at XMLOutputter outputElementContent().  That's what it's meant to
>do.  You might find a bug tho.  I remember Alex Chaffee who wrote the
>method griped about something not being 100% right.  Alex?

I couldn't find outputElementContent(), but could find
printElementContent(); However, I just noticed that XMLOutputter's
outputString(Element) does return the whole element content. I don't know
about the known bug in the pringElementContent(), but if I strip out element
tags from a return value of outputString, the method does exactly what I
wanted to do.

I really appreciate your information.

Masaki




More information about the jdom-interest mailing list