Hi friends how to remove duplicate data in xml? in c#
in below xml material code is duplicate so i need to remove that forecast details.. please Help
<rootnode>
<ForecastDetails>
<Year>2019</Year>
<Month>04</Month>
<Material_Code>1422346</Material_Code>
<Position_Code>BL</Position_Code>
<PeakSale>0</PeakSale>
<AverageSale>0</AverageSale>
<Apr>0</Apr>
<May>0</May>
<Jun>0</Jun>
<Jul>0</Jul>
<Aug>0</Aug>
<Sep>0</Sep>
</ForecastDetails>
<ForecastDetails>
<Year>2019</Year>
<Month>04</Month>
<Material_Code>1422346</Material_Code>
<Position_Code>BL</Position_Code>
<PeakSale>0</PeakSale>
<AverageSale>0</AverageSale>
<Apr>0</Apr>
<May>0</May>
<Jun>0</Jun>
<Jul>0</Jul>
<Aug>0</Aug>
<Sep>0</Sep>
</ForecastDetails>
</rootnode>
XDocument xDoc = XDocument.Parse(xml);
xDoc.Root.Elements("test")
.SelectMany(s => s.Elements("ForecastDetails")
.GroupBy(g => g.Attribute("Material_Code").Value)
.SelectMany(m => m.Skip(1))).Remove();
string testing = xDoc.ToString();