[jdom-interest] Recursively Modifying the JDOM before output.

Gary Montgomery Gary.Montgomery at G11N.COM
Fri Jun 1 13:35:56 PDT 2001


> > This works, but I sure would like to understand why 
> setText() causes element
> > to loose it's children. Or if there is something
> > else going on here, what it is.
> 
> Picture this:
> 
> <root>
>   Here is some text
>   <kid/>
>   Here is more text
> </root>
> 
> getText() returns "\n  Here is some text\n  \n  Here is more text".
> 
> Now, what should setText("foo") do to the tree?
> 
> -jh-
> 

Ah, I see. Makes sense. 

So we save <kid/> off to the side with getChildren(). setText("foo") changes
the tree
to:
 
<root>
foo
</root>

then after addChildren():

<root>
foo
<kid/>
</root>

Thanks,
Gary



More information about the jdom-interest mailing list