Is there a simple way, possibly with open-source command line tools in Linux, to strip all levels beyond a given threshold from a given XML document, regardless of the structure?
Input:
<a att="1">
<b/>
<c bat="2">
<d/>
</c>
</a>
Output, level=1:
<a att="1"/>
Output, level=2:
<a att="1">
<b/>
<c bat="2"/>
</a>
I have tried XPath but was unable to restrict the level.
Very simple in XSLT: