Return XML structure up to the n-th level

coldblo0d

New Member
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:\[code\]<a att="1"> <b/> <c bat="2"> <d/> </c></a>\[/code\]Output, level=1:\[code\]<a att="1"/>\[/code\]Output, level=2:\[code\]<a att="1"> <b/> <c bat="2"/></a>\[/code\]I have tried XPath but was unable to restrict the level.
 
Back
Top