I have a nested hierarchial xml structure which is to be flattened using xsl transformation. Following is the scenario.
<company>
<Managers>
<Manager>
<Name>Matt</Name>
<ID>1</ID>
<Manager>
<Name>Joe</Name>
<ID>11</ID>
<Manager>
<Name>Dave</Name>
<ID>111</ID>
</Manager>
</Manager>
</Manager>
<Manager>
<Name>mike</Name>
<ID>2</ID>>
</Manager>
</Managers>
</company>
result:
Matt 1
Joe 11
Dave 111
Mike 2
A better alternative via @Mathias Mueller,
Why this is better: It will more properly control the text output (assuming you really do want to output this to plaintext format). It also is more XSLT template oriented, which tends to be more extensible and maintainable than having
for-each
loops hanging around.Using the
descendant-or-self
axis:Output:
http://xsltransform.net/nc4NzQB