[jdom-interest] removing pcdata from jdom-Elements

Kai Wörner kai.woerner at uni-hamburg.de
Fri Mar 11 05:36:08 PST 2005


Hi all,

I want to do this to a XML-Document:

(before:)
<s>someone said: <q>this sucks bigtime</q> and i agreed</s>

(after:)
<s><w>someone</w><w>said:</w><q><w>this</w><w>sucks</w><w>bigtime</w></q><w>
and</w><w>i</w><w>agreed</w></s>

I thought I'll get all Elements via

Iterator myI = doc.getDescendants(new ElementFilter());

iterate through them, look for PCDATA via Element.getText, chop it with a
StringTokenizer, add the Tokens as new <w>-Elements to the actual Element
and get rid of the PCDATA itself. But how do I do this? Is there something
like Element.removeContent(new onlyThePCDATAContentSparingElementsFilter())?

Thanks

Kai



More information about the jdom-interest mailing list