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 vie开发者_开发百科w attribute. This elements shouldn't be selected.
string selector = "XXX";
Elements.Where(x => x.Name == "Item"
&& x.Attribute("view") != null
&& x.Attribute("view").Value != selector).Remove();
精彩评论