Linq to XML. Select particular Descendants

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi All,
I have the following XML
<XMLNODE_1 attr1="" attr2="
<XMLNODE_2>
<XMLNODE_3></XMLNODE_3>
<XMLNODE_3></XMLNODE_3>
<XMLNODE_3></XMLNODE_3>
< XMLNODE_4>
<XMLNODE_3>
<XMLNODE_3>
</ XMLNODE_4>
<XMLNODE_2>
</XMLNODE_1>

I have got the XElement of XMLNODE_2 in an object. When i execute
xmlnode2.Descendants("XMLNODE_3");
I get all the XMLNODE_3 tags ie 5 (includes the nodes under XMLNODE_4 also)
How can I get the XMLNODE_3 nodes which are only under XMLNODE_2 and
NOT under XMLNODE_4


View the full article
 
Back
Top