Reputation: 4369
I'd like to remove all elements of type Item
with an attribute view
which has not a certain value.
So if the value is XXX. Select all elements Item which have an attribute view of value != XXX.
Some of the Item elements don't have a view attribute. This elements shouldn't be selected.
Upvotes: 1
Views: 1845
Reputation: 35399
string selector = "XXX";
Elements.Where(x => x.Name == "Item"
&& x.Attribute("view") != null
&& x.Attribute("view").Value != selector).Remove();
Upvotes: 4