score:2

Accepted answer
xelement root = xelement.load(file); // .parse(string)
list<string> names = root.descendants().distinct(x => x.name.localname).tolist();
names.foreach(name => root.descendants(name).skip(1).remove());
root.save(file); // or root.tostring()

score:0

 foreach (xmlnode child 
   in node.childnodes.distinct(custom comparer that looks on node names))
{
.....
}

Related Query

More Query from same tag