Using
/*/L/D/node()
This selects all nodes (elements, text nodes, processing instructions, and comment nodes) that are children of any element D , which is a child of any element L , which is a child of the top element of the XML document.
Alternatively, you can select separately all node -children from two /*/L/D elements :
/*/L[1]/D/node()
and
/*/L[2]/D/node()
Validation using XSLT as the XPath host :
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output omit-xml-declaration="yes" indent="yes"/> <xsl:template match="/"> <xsl:copy-of select="/*/L[1]/D/node()"/> -------------------- <xsl:copy-of select="/*/L[2]/D/node()"/> </xsl:template> </xsl:stylesheet>
when applied to the provided XML document :
<MAIN> <L> <D>string1 string2 <b>string3</b> string4 </D> </L> <L> <D>string5 string6 <b>string7</b> string8 <i>string9</i> </D> </L> </MAIN>
required, the correct result is obtained :
string1 string2 <b>string3</b> string4 -------------------- string5 string6 <b>string7</b> string8 <i>string9</i>
source share