I have the following XML structure from which I want to select/remove the "second" Element which has the Attribute "Name" whose value = "Test"
Anyway what I have above does not work, and I've tried a lot of different things to no avail. There is something important that I seem to be missing about LINQ to XML. I read that I should be able to use Descendants() anywhere (without having to specify the hierarchy in element.element type syntax), but I haven't gotten that to work with a where clause or condition.
Code:
<Application>
<first>
<second Name="Test">
</second>
<second Name="Whatever">
</second>
</first>
</Application>
var x = from c in xd.Element("Application").Element("first").Descendants()
where c.Element("Application").Element("first").Element("second").Attribute("Name").Value=="Test"
select c;
Comment