<Category id=1>
<MyLines>
<Line GroupID="0" Cache="15" />
<Rect GroupID="0" Cache="16"/>
<Ellipse GroupID="0" Cache="16"/>
</MyLines>
My XML document contains many Category tags. Could you please let me know what is the best way to get each of the sub elements of MyLines whose Cache = 16 and remove them.
I am looking to achieve this using linq.
I was trying as below:
var q = from node in doc.Descendants("MyLines")
let attr = node.Attribute("Cache")
where attr != null && Convert.ToInt32(attr.Value) == 16
select node;
q.ToList().ForEach(x => x.Remove());