XmlDocument returnXml = new XmlDocument(); returnXml.Load(@"F:\Temp\CBNOTDupicate.xml"); Func<XmlNode,string> delegateOfCBNOT = delegate(XmlNode node) { return node.SelectSingleNode("CB_Adjustment_number").InnerText.Trim() + "," + node.SelectSingleNode("Ind_Ref_Number").InnerText.Trim(); }; string[] groupByColumnsForCBNOT = { "CB_Adjustment_number","Ind_Ref_Number" }; bool haveDuplicate = false; var duplicatedRecordsTemp = returnXml.SelectNodes("CBNOTReportModel/CBNOTDetailRecords/CBNOTDetailRecord").Cast<XmlNode>(); var duplicatedRecords = returnXml.SelectNodes("CBNOTReportModel/CBNOTDetailRecords/CBNOTDetailRecord").Cast<XmlNode>(). GroupBy(r => delegateOfCBNOT(r)). Where(q => q.Count() > 1);