Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » JDOM User »

[jdom-interest] removing pcdata from jdom-Elements

Kai Woerner

2005-03-11

Replies:

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

_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@(protected)
©2008 junlu.com - Jax Systems, LLC, U.S.A.