Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/279.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何从xml输出中删除_C#_Xml_Serialization - Fatal编程技术网

C# 如何从xml输出中删除

C# 如何从xml输出中删除,c#,xml,serialization,C#,Xml,Serialization,我有一个服务,它接收行数据文本并将数据解析为XML格式。该服务正在工作,但是在节点的输出上,我得到的是anyType xsi:type=R0001,而不仅仅是R0001。我已经尝试了在StackOverflow上找到的几个建议,但它们似乎都不适用于我的代码。有人有什么建议吗?请参见提供的示例: using System; using System.Collections.Generic; using System.Xml.Serialization; namespace Client_Data

我有一个服务,它接收行数据文本并将数据解析为XML格式。该服务正在工作,但是在节点的输出上,我得到的是anyType xsi:type=R0001,而不仅仅是R0001。我已经尝试了在StackOverflow上找到的几个建议,但它们似乎都不适用于我的代码。有人有什么建议吗?请参见提供的示例:

using System;
using System.Collections.Generic;
using System.Xml.Serialization;

namespace Client_Data_Parser
{
    public class Records
    {
        public List<Record> WCErecords { get; set; }
    }

    [XmlInclude(typeof(R0001))]
    [XmlInclude(typeof(R0002))]
    [XmlInclude(typeof(R0003))]
    [XmlInclude(typeof(R0004))]
    [XmlInclude(typeof(R0005))]
    [XmlInclude(typeof(R0006))]
    [XmlInclude(typeof(R0007))]
    [Serializable()]
    public class Record
    {
        public List<object> DataSet { get; set; }
    }
    [Serializable()]
    public class R0001
    {
        public string RecKey { get; set; }
        public string RecordType { get; set; }
        public string ABFKey { get; set; }
        public string FormRelationCode { get; set; }
        public string RecipientCode { get; set; }
        public string ClaimType { get; set; }
        public string PullCode { get; set; }
        public string SendToName { get; set; }
        public string SentToAddress1 { get; set; }
        public string SendToAddress2 { get; set; }
        public string SendToCity { get; set; }
        public string SendToState { get; set; }
        public string SendToZip { get; set; }
        public string ForeignCountry { get; set; }
        public string EmailAddress { get; set; }
        public string FaxNumber { get; set; }
        public string MailID { get; set; }
    }

    [Serializable()]
    public class R0002
    {
        public string RecordType { get; set; }
        public string ABFKey { get; set; }
        public string InsuredSeqNum { get; set; }
        public string RunNumSeq { get; set; }
        public string DraftCode { get; set; }
        public string PreauthorizationFlag { get; set; }
        public string MemberName { get; set; }
        public string MemberSSN { get; set; }
        public string ClaimantAddress1 { get; set; }
        public string ClaimantAddress2 { get; set; }
        public string ClaimantAddress3 { get; set; }
        public string ClaimantCountry { get; set; }
        public string ClaimantName { get; set; }
        public string ClaimantDOB { get; set; }
        public string ClaimantsNumber { get; set; }
        public string ClaimantsAcctNum { get; set; }
        public string ClaimantsRelation { get; set; }
        public string ClaimNumber { get; set; }
        public string ExaminerCode { get; set; }
        public string ExaminerName { get; set; }
        public string ReceivedDate { get; set; }
        public string EntryDate { get; set; }
        public string ReleasedDate { get; set; }
        public string DISDailyBenefitRate { get; set; }
        public string DISWeeklyBenefitRate { get; set; }
        public string DISType { get; set; }
        public string DISBenefitDays { get; set; }
        public string DISBenefitWeeks { get; set; }
        public string DISInjuryDate { get; set; }
        public string DISBackToWorkDate { get; set; }
        public string DISLastWorkDate { get; set; }
        public string DISLastBenefitDate { get; set; }
        public string DIS_YTDTotalAmount { get; set; }
        public string ProviderTIN { get; set; }
        public string BillingProviderName { get; set; }
        public string ServiceProviderName { get; set; }
        public string ProviderAddress1 { get; set; }
        public string ProviderAddress2 { get; set; }
        public string ProviderAddress3 { get; set; }
        public string ProviderCountry { get; set; }
        public string FundCode { get; set; }
        public string FundName { get; set; }
        public string FundAddress1 { get; set; }
        public string FundAddress2 { get; set; }
        public string FundAddress3 { get; set; }
        public string GroupCode { get; set; }
        public string GroupName { get; set; }
        public string GroupAddress1 { get; set; }
        public string GroupAddress2 { get; set; }
        public string GroupAddress3 { get; set; }
        public string Subgroup { get; set; }
        public string SubgroupName { get; set; }
        public string Local { get; set; }
        public string BenefitPlanCode { get; set; }
        public string BenefitPlanDescription { get; set; }
        public string CoverageCode { get; set; }
        public string CoverageDescription { get; set; }
        public string AgentCode { get; set; }
        public string AgentName { get; set; }
        public string EmployerCode { get; set; }
        public string EmployerName { get; set; }
        public string ClaimAssignment { get; set; }
        public string PrintDate { get; set; }    
    }

    [Serializable()]
    public class R0003
    {
        public string RecordType { get; set; }
        public string ABFKey { get; set; }
        public string InsuredSeqNum { get; set; }
        public string LineItemNum { get; set; }
        public string FromDate { get; set; }
        public string ThruDate { get; set; }
        public string ProcedureCode { get; set; }
        public string Modifier { get; set; }
        public string DiagnosisCode1 { get; set; }
        public string DiagnosisCode2 { get; set; }
        public string DiagnosisCode3 { get; set; }
        public string DiagnosisCode4 { get; set; }
        public string ToothSurface1 { get; set; }
        public string ToothSurface2 { get; set; }
        public string ToothSurface3 { get; set; }
        public string Quantity { get; set; }
        public string ServiceDescription { get; set; }
        public string Billed { get; set; }
        public string TotalLineItemIneligAmt { get; set; }
        public string PayType1 { get; set; }
        public string PayType2 { get; set; }
        public string PayType3 { get; set; }
        public string DiscountAmount { get; set; }
        public string CoveredAmount { get; set; }
        public string PlanAllowedAmount1 { get; set; }
        public string PlanAllowedAmount2 { get; set; }
        public string PlanAllowedAmount3 { get; set; }
        public string DeductibleType1 { get; set; }
        public string DeductibleType2 { get; set; }
        public string DeductibleType3 { get; set; }
        public string Deductible1 { get; set; }
        public string Deductible2 { get; set; }
        public string Deductible3 { get; set; }
        public string NetAllowed1 { get; set; }
        public string NetAllowed2 { get; set; }
        public string NetAllowed3 { get; set; }
        public string CoinsuranceRate1 { get; set; }
        public string CoinsuranceRate2 { get; set; }
        public string CoinsuranceRate3 { get; set; }
        public string GrossCovered1 { get; set; }
        public string GrossCovered2 { get; set; }
        public string GrossCovered3 { get; set; }
        public string COBAdjustment1 { get; set; }
        public string COBAdjustment2 { get; set; }
        public string COBAdjustment3 { get; set; }
        public string NetCovered1 { get; set; }
        public string NetCovered2 { get; set; }
        public string NetCovered3 { get; set; }
        public string NetCoveredDiscount { get; set; }
        public string LineItemPaid { get; set; }
        public string PatientLiabilityAmount { get; set; }
        public string ProviderLiabilityAmount { get; set; }
        public string FSALiabilityAmount { get; set; }
        public string PrepaidInsured { get; set; }
        public string PrepaidOtherInsurance { get; set; }
        public string PrepaidMedicare { get; set; }
        public string PPOcode { get; set; }
        public string PPOdescription { get; set; }
        public string DISGrossBenefit { get; set; }
        public string DISWithholdingType1 { get; set; }
        public string DISWithholdingDescription1 { get; set; }
        public string DISWithholdingAmount1 { get; set; }
        public string DISWithholdingType2 { get; set; }
        public string DISWithholdingDescription2 { get; set; }
        public string DISWithholdingAmount2 { get; set; }
        public string DISWithholdingType3 { get; set; }
        public string DISWithholdingDescription3 { get; set; }
        public string DISWithholdingAmount3 { get; set; }
        public string DISWithholdingType4 { get; set; }
        public string DISWithholdingDescription4 { get; set; }
        public string DISWithholdingAmount4 { get; set; }
        public string DISWithholdingType5 { get; set; }
        public string DISWithholdingDescription5 { get; set; }
        public string DISWithholdingAmount5 { get; set; }
        public string DISWithholdingType6 { get; set; }
        public string DISWithholdingDescription6 { get; set; }
        public string DISWithholdingAmount6 { get; set; }
        public string DISWithholdingType7 { get; set; }
        public string DISWithholdingDescription7 { get; set; }
        public string DISWithholdingAmount7 { get; set; }
        public string DISWithholdingType8 { get; set; }
        public string DISWithholdingDescription8 { get; set; }
        public string DISWithholdingAmount8 { get; set; }
        public string DISWithholdingType9 { get; set; }
        public string DISWithholdingDescription9 { get; set; }
        public string DISWithholdingAmount9 { get; set; }
        public string DISWithholdingType10 { get; set; }
        public string DISWithholdingDescription10 { get; set; }
        public string DISWithholdingAmount10 { get; set; }
        public string DISNetBenefitDue { get; set; }
        public string DISTotalPayable { get; set; }
        public string LineItemRemarkCode1 { get; set; }
        public string LineItemRemarkCode2 { get; set; }
        public string LineItemRemarkCode3 { get; set; }
        public string LineItemRemarkCode4 { get; set; }
        public string LineItemRemarkCode5 { get; set; }
        public string LineItemRemarkCode6 { get; set; }
        public string LineItemRemarkCode7 { get; set; }
        public string LineItemRemarkCode8 { get; set; }
        public string LineItemRemarkCode9 { get; set; }
        public string LineItemRemarkCode10 { get; set; }
        public string AmountNotCoveredByInsurance { get; set; }
    }

    [Serializable()]
    public class R0004
    {
        public string RecordType { get; set; }
        public string ABFKey { get; set; }
        public string InsuredSeqNum { get; set; }
        public string TotalBilled { get; set; }
        public string TotalLineItemIneligAmt { get; set; }
        public string TotalDiscountAmount { get; set; }
        public string TotalCoveredAmount { get; set; }
        public string TotalPlanAllowedAmount { get; set; }
        public string TotalDeductible { get; set; }
        public string TotalNetAllowed { get; set; }
        public string TotalGrossCovered { get; set; }
        public string TotalCOBadjustment { get; set; }
        public string TotalNetCovered { get; set; }
        public string TotalNetCoveredDiscount { get; set; }
        public string TotalPatientLiabilityAmt { get; set; }
        public string TotalProviderLiability { get; set; }
        public string TotalFSAliabilityAmount { get; set; }
        public string TotalPrepaidInsured { get; set; }
        public string TotalPrepaidOther { get; set; }
        public string TotalPrepaidMedicare { get; set; }
        public string TotalPriorPmtAdjustment { get; set; }
        public string TotalPaidPlan1 { get; set; }
        public string TotalPaidPlan2 { get; set; }
        public string TotalPaid { get; set; }
        public string DISGrossBenefit { get; set; }
        public string DISWithholdingType1 { get; set; }
        public string DISWithholdingAmount1 { get; set; }
        public string DISWithholdingType2 { get; set; }
        public string DISWithholdingAmount2 { get; set; }
        public string DISWithholdingType3 { get; set; }
        public string DISWithholdingAmount3 { get; set; }
        public string DISWithholdingType4 { get; set; }
        public string DISWithholdingAmount4 { get; set; }
        public string DISWithholdingType5 { get; set; }
        public string DISWithholdingAmount5 { get; set; }
        public string DISWithholdingType6 { get; set; }
        public string DISWithholdingAmount6 { get; set; }
        public string DISWithholdingType7 { get; set; }
        public string DISWithholdingAmount7 { get; set; }
        public string DISWithholdingType8 { get; set; }
        public string DISWithholdingAmount8 { get; set; }
        public string DISWithholdingType9 { get; set; }
        public string DISWithholdingAmount9 { get; set; }
        public string DISWithholdingType10 { get; set; }
        public string DISWithholdingAmount10 { get; set; }
        public string DISNetBenefitDue { get; set; }
        public string DISTotalPayable { get; set; }
        public string LineItemRemarkCode1 { get; set; }
        public string LineItemRemarkCode2 { get; set; }
        public string LineItemRemarkCode3 { get; set; }
        public string LineItemRemarkCode4 { get; set; }
        public string LineItemRemarkCode5 { get; set; }
        public string LineItemRemarkCode6 { get; set; }
        public string LineItemRemarkCode7 { get; set; }
        public string LineItemRemarkCode8 { get; set; }
        public string LineItemRemarkCode9 { get; set; }
        public string LineItemRemarkCode10 { get; set; }
        public string DISContinuationFormFlag { get; set; }
        public string AmountNotCoveredByInsurance { get; set; }
    }

    [Serializable()]
    public class R0005
    {
        public string RecordType { get; set; }
        public string ABFKey { get; set; }
        public string InsuredSeqNum { get; set; }
        public string ClaimNumber { get; set; }
        public string LineItemNumber { get; set; }
        public string CommentRemarkCode { get; set; }
        public string Comment { get; set; }
    }

    [Serializable()]
    public class R0006
    {
        public string RecordType { get; set; }
        public string ABFKey { get; set; }
        public string InsuredSeqNum { get; set; }
        public string PayeeName { get; set; }
        public string CheckNumber { get; set; }
        public string CheckAmount { get; set; }
        public string CheckDate { get; set; }
    }

    [Serializable()]
    public class R0007
    {
        public string RecordType { get; set; }
        public string ABFKey { get; set; }
        public string CheckNumber { get; set; }
        public string CheckAmount { get; set; }
        public string CheckDate { get; set; }
        public string MicrCheckNumber { get; set; }
        public string MicrOnusNumber { get; set; }
        public string MicrTransitNumber { get; set; }
        public string BankName { get; set; }
        public string BankAddress1 { get; set; }
        public string BankAddress2 { get; set; }
        public string BankCityStateZip { get; set; }
        public string BankCountry { get; set; }
        public string PayeeTIN { get; set; }
        public string PayeeName { get; set; }
        public string PayeeAddress1 { get; set; }
        public string PayeeAddress2 { get; set; }
        public string PayeeCityStateZip { get; set; }
        public string PayeeCountry { get; set; }
        public string CheckAmountText { get; set; }
        public string FractionalRoutingNumber { get; set; }
    }
}
我正在创建一个包含类记录的对象列表,每个记录类型都与之对应。每个记录都会添加到记录类列表中,但在输出时,我的XML如下所示:

<!-- language: lang-xml -->
<?xml version="1.0"?>
<Records xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <WCErecords>
    <Record>
      <DataSet>
        <anyType xsi:type="R0001">
          <RecKey>0000000201612191200000304</RecKey>
          <RecordType>0001</RecordType>
          <ABFKey>0000000201612191200000304</ABFKey>
          <FormRelationCode>001</FormRelationCode>
          <RecipientCode>P </RecipientCode>
          <ClaimType>MED</ClaimType>
          <PullCode>  </PullCode>
          <SendToName>SETH L IVINS MD</SendToName>
          <SentToAddress1>PO BOX 71256</SentToAddress1>
          <SendToAddress2 />
          <SendToCity>PHILA</SendToCity>
          <SendToState>PA</SendToState>
          <SendToZip>19176</SendToZip>
          <ForeignCountry />
          <EmailAddress />
          <FaxNumber>          </FaxNumber>
          <MailID>                              </MailID>
        </anyType>
       </DataSet>
    </Record>
  </WCErecords>
</Records>
如果需要任何附加信息或代码,请告诉我。上面的XML只是一个示例,只包含一种数据类型,这样页面就不会被大量文本淹没。因此,我要寻找的是删除anyType xsi:type并使其仅读取R0001。

为集合中的每个可能类型添加属性XmlArrayItem,如:

[XmlArrayItem(typeof(R0001), ElementName = "R0001")]
[XmlArrayItem(typeof(R0002), ElementName = "R0002")]
[XmlArrayItem(typeof(R0003), ElementName = "R0003")]
public List<object> DataSet { get; set; }