比较多个XML文件

时间:2019-02-11 09:42:11

标签: c# xml

我从我写的原始帖子中重新措辞:我有两个XML文件,它们分别与给定的年份相关。例如18/19和17/18。它们符合相同的结构,下面是这些文件之一的小样本。我想要的是,在C#中,比较这些文件中的所有记录,其中给定名称,姓氏,NI编号和出生日期相同,但学习者编号则不同。我需要能够进行比较,然后仅将这些记录推送到数据表中,以便随后将它们推送到电子表格中(我可以做的电子表格位)。我目前将以下内容作为起点,但仍然非常困难。

首先,我需要按下导入按钮:

private void Btn_Import_Click(object sender, RoutedEventArgs e)
{
    ILRChecks.ILRReport.CrossYear();
}

然后看一下Class,最终将文件推送到我的位置:

using System.Data;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ILRValidation;
using InfExcelExtension;

namespace ILRChecks
{
    internal static partial class ILRReport
    {
       internal static void CrossYear()
       {
           DataSet ds_CrossYearChecks = 
ILRValidation.Validation.CrossYearChecks(Global.fileNames);
           string output = Path.Combine(Global.foldername, "ULIN_Issues" + 
".xlsx");
           ds_CrossYearChecks.ToWorkBook(output); 
      }
   }
}

这就是我要坚持的一点,它是发现差异的结果:

using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ILRValidation
{
     public static partial class Validation
    {
          public static DataSet CrossYearChecks(DataSet ds_CrossYearChecks)
         {
              return CrossYearChecks(ds_CrossYearChecks);
         }

         public static DataSet CrossYearChecks(string[] xmlPath)
         {
              DataSet ds_xmlCrossYear = new DataSet();  
              return CrossYearChecks(ds_xmlCrossYear);
         }
     }
}

XML:

<Learner>
<LearnRefNumber></LearnRefNumber>
<ULN></ULN>
<FamilyName></FamilyName>
<GivenNames></GivenNames>
<DateOfBirth></DateOfBirth>
<Ethnicity></Ethnicity>
<Sex></Sex>
<LLDDHealthProb></LLDDHealthProb>
<NINumber></NINumber>
<PriorAttain></PriorAttain>
<MathGrade></MathGrade>
<EngGrade></EngGrade>
<PostcodePrior></PostcodePrior>
<Postcode></Postcode>
<AddLine1></AddLine1>
<AddLine3></AddLine3>
<Email></Email>
<LearnerEmploymentStatus>
  <EmpStat>10</EmpStat>
  <DateEmpStatApp>2015-09-01</DateEmpStatApp>
  <EmpId>153421665</EmpId>
  <EmploymentStatusMonitoring>
    <ESMType>LOE</ESMType>
    <ESMCode>4</ESMCode>
  </EmploymentStatusMonitoring>
  <EmploymentStatusMonitoring>
    <ESMType>EII</ESMType>
    <ESMCode>4</ESMCode>
  </EmploymentStatusMonitoring>
</LearnerEmploymentStatus>
<LearningDelivery>
  <LearnAimRef></LearnAimRef>
  <AimType></AimType>
  <AimSeqNumber></AimSeqNumber>
  <LearnStartDate></LearnStartDate>
  <LearnPlanEndDate></LearnPlanEndDate>
  <FundModel></FundModel>
  <ProgType></ProgType>
  <StdCode></StdCode>
  <DelLocPostCode></DelLocPostCode>
  <CompStatus></CompStatus>
  <SWSupAimId></SWSupAimId>
  <LearningDeliveryFAM>
    <LearnDelFAMType></LearnDelFAMType>
    <LearnDelFAMCode></LearnDelFAMCode>
    <LearnDelFAMDateFrom></LearnDelFAMDateFrom>
  </LearningDeliveryFAM>
  <LearningDeliveryFAM>
    <LearnDelFAMType></LearnDelFAMType>
    <LearnDelFAMCode></LearnDelFAMCode>
  </LearningDeliveryFAM>
  <LearningDeliveryFAM>
    <LearnDelFAMType></LearnDelFAMType>
    <LearnDelFAMCode></LearnDelFAMCode>
  </LearningDeliveryFAM>
  <LearningDeliveryFAM>
    <LearnDelFAMType></LearnDelFAMType>

0 个答案:

没有答案