Search code examples
xmlxmlstarlet

delete an element but keep contents in parent element in xmlstarlet


I'm using xmlstarlet and want to convert elements of this sort:

<entry>
<para>Text</para>
</entry>
<entry>
<para>
<emphasis role=bold>text</emphasis>
</para>

to:

<entry>Text</entry>
<entry><emphasis role=bold>text</emphasis></entry>

Is this possible in xmlstarlet?

Any help is greatly appreciated!

thanks,

Russ


Solution

  • xmlstarlet ed -u //para/.. -x 'para/node()' para.xml
    

    Which means: repace contents of every para parent with the contents of the para. Requires version 1.4.0+