[jdom-interest] Remove all occurencies of an element
philip.nelson at omniresources.com
philip.nelson at omniresources.com
Mon Mar 26 12:36:21 PST 2001
Honestly, a style sheet would work well for this. In JDOM, you would find
the content you wish to save using normal collection methods. Then detach()
those elements. Then delete the parent elements. Then add the detached
elements in the correct place.
> Remove all occurencies of an element
>
> I have some rather complex XML documents that I want to
> reduces, by removing the "unwanted" elements and attributes.
>
> Example 1: (removing both the element and text node)
>
> <A>
> <B>
> <C>
> <D>
> <C/>
> </D>
> </C>
> </B>
> </A>
>
> The wanted result 1: (after all the C-elements are removed
> from the document )
>
> <A>
> <B>
> <D>
> </D>
> </B>
> </A>
>
>
> Example 2: (removing the C-element but keeping the text node)
>
> <A>
> <B>
> <C>
> <D>The
> <C>blue </C>
> </D>color is ....
> </C>
> </B>
> </A>
>
> The wanted result 2: (after the C-element is removed)
>
> <A>
> <B>
> <D>
> The blue color is ....
> </D>
> </B>
> </A>
>
> To my understanding the removeChildren(java.lang.String name)
> removes the children one level deep and it also removes the
> childrens children. So this can't be used.
>
> Does any one have an idéar how to do this?
>
> Regards, Niels Peter
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/yo
uraddr at yourhost.com
More information about the jdom-interest
mailing list