hi i have the following xml
<students>
<student>
<id>12</id>
<name>Mohsan</name>
</student>
<student>
<id>2</id>
<name>Ali</name>
<address>
<country>Pakistan</country>
</address>
<address>
<country>India</country>
</address>
<parent>
<id>12</id>
<address>
<country>Pakistan</country>
</address>
</parent>
</student>
<student>
<id>3</id>
<name>Azhar</name>
</student>
</students>
i want to get the address of student only. not the address of its parent. i used this query
var stds = from std in doc.Descendants("student")
select new
{
ID = std.Element("id").Value,
Name = std.Element("name").Value,
Address = from addr in std.Descendants("address")
select addr.Element("country").Value
};
but this query returning me address of its parent too. which i dont want. note that a student can have multiple address. please tell me how to exclude the parent address at the time of retrieval..