XSLT - delete element[s] but keep contents
Posted: Wed Dec 08, 2010 2:11 pm
I'm trying to learn XSLT.
I have a lot of XML docs and need to delete an XML element, wherever it occurs within the node tree.
The element has optional attributes and an optional child - I need to delete the parent, its attributes, the optional child (where it occurs) but leave the element contents in tact.
E.g.
<para>
Text text <movie alttitle="The Terror" year="2010"><title>Really Scared</title>, distributed by Hopeless Pictures</movie> text text
</para>
How would I use XSLT to find and remove all <movie/> elements, inc all <title> elements to leave:
<para>
Text text Really Scared, distributed by Hopeless Pictures text text
</para>
?
I have a lot of XML docs and need to delete an XML element, wherever it occurs within the node tree.
The element has optional attributes and an optional child - I need to delete the parent, its attributes, the optional child (where it occurs) but leave the element contents in tact.
E.g.
<para>
Text text <movie alttitle="The Terror" year="2010"><title>Really Scared</title>, distributed by Hopeless Pictures</movie> text text
</para>
How would I use XSLT to find and remove all <movie/> elements, inc all <title> elements to leave:
<para>
Text text Really Scared, distributed by Hopeless Pictures text text
</para>
?