I have codes like this;
XElement TEST = XElement.Parse(
@"<SettingsBundle>
    <SettingsGroup Id=""QAVerificationSettings"">
        <Setting Id=""RegExRules"">True</Setting>
        <Setting Id=""RegExRules1""><RegExRule><Description>Foo</Description><IgnoreCase>false</IgnoreCase><RegExSource></RegExSource><RegExTarget>[^\s]+@[^\s]+</RegExTarget><RuleCondition>TargetOnly</RuleCondition></RegExRule></Setting>
        <Setting Id=""RegExRules2""><RegExRule><Description>Boo</Description><IgnoreCase>false</IgnoreCase><RegExSource></RegExSource><RegExTarget>\s{2,}</RegExTarget><RuleCondition>TargetOnly</RuleCondition></RegExRule></Setting>
        <Setting Id=""RegExRules2""><RegExRule><Description>Boo</Description><IgnoreCase>false</IgnoreCase><RegExSource></RegExSource><RegExTarget>\s{2,}</RegExTarget><RuleCondition>TargetOnly</RuleCondition></RegExRule></Setting>
    </SettingsGroup>
</SettingsBundle>");
List<XElement> LIST1 = new List<XElement> { };
foreach( XElement x in TEST.Descendants( "RegExRule"))
    LIST1.Add(x);
var LIST2 = LIST1.Distinct();           
var NEW = new XDocument(
    new XElement("SettingsBundle",
        new XElement("SettingsGroup", new XAttribute("Id", "QAVerificationSettings"),
            new XElement("Settings", new XAttribute("Id", "RegExRules"), "True"),
            LIST2.Select((x, i) => new XElement("Setting", new XAttribute("Id", "RegExRules" + i ), x ))
    )));
NEW.Save(Directory.GetCurrentDirectory() + @"\_Texting.xml");
I'd like to delete one of the same item (I need only one "RegExRules2" not two).
But, have failed.
What do I have to do ? (I guess, I am not good at with "Distinct()")
Thanks
 
     
     
    