Check duplicate in xml file with specific columns

前端之家收集整理的这篇文章主要介绍了Check duplicate in xml file with specific columns前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
            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);

猜你在找的XML相关文章