Retrieving leaves from differently branched parent nodes with C# in an XML document

partner

New Member
\[code\]<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> \[/code\]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.
 
Back
Top