Reading all the leaf nodes for a given Parent Node



I need a list of leaf nodes under the given parent node body. Basically I want all the nodes like 11 and 10 from the below XML.


I tried this but it brings all the nodes. //[not()]


for example I want to give something like this var vNode= nodeBody.SelectNodes("Body"+@"//[not()]");


which should get be all the leaf nodes under Body.



<MAIN Txt="PC">
<BODY Txt="TC">
<Element_3 Txt="OC">
<Element3_ID Name="yoy">10</Element3_ID>
</Element_3>
<Element_3 Txt="TRO">
<Element_4 Txt="SSO">
<Element4_ID Name="JOY">11</Element4_ID>
<Element4_ID Name="TOY">13</Element4_ID>
<Element4_ID Name="POY">14</Element4_ID>
<Element4_ID Name="SOY">17</Element4_ID>
<Element4_ID Name="GOY">18</Element4_ID>
<Element4_ID Name="FOY">19</Element4_ID>
</Element_4>
</Element_3>
</BODY>
</MAIN>

No comments:

Post a Comment