<Root>
<P1 Text ="A" >
<P2 Text = "AA">
<P3 Text = "AAA">
<L Text = "l_A"/>
<L Text = "l_B"/>
<L Text = "l_C"/>
</P3>
<P3 Text = "BBB">
<L Text = "l_D"/>
<L Text = "l_E"/>
<L Text = "l_F"/>
</P3>
</P2>
<P2 Text = "BB">
<L Text = "l_G"/>
<L Text = "l_H"/>
<L Text = "l_I"/>
</P2>
</P1>
</Root>
From an XML document containing thousands of variably nested nodes up to 10 levels deep, I
would like to retrieve programmatically only the leaves belonging to any of the “P” parents
as follows: for instance, in the example above, selecting P2 “AA” would yield l_A to l_F and P3 “BBB” would give l_D to l_F.
Something like this (returns a list of strings):
You may remove the attribute null checks if the
Textattribute is always there…