Using
/*/node()
This selects all the child nodes of the top element of the XML document. The set of all these nodes has exactly the required subtree structure, because each selected element retains its entire subtree (of which this element is the top node).
XSLT Based Validation :
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output omit-xml-declaration="yes" indent="yes"/> <xsl:strip-space elements="*"/> <xsl:template match="/"> <xsl:copy-of select="/*/node()"/> </xsl:template> </xsl:stylesheet>
when this conversion is applied to the provided XML document :
<a> <b> <c> data </c> </b> </a>
the XPath expression is evaluated and the selected nodes are displayed, which leads to the desired, correct result :
<b> <c> data </c> </b>
source share