每当我使用带有某些输入的Google chrome将请求传递到Web服务Web方法时,都会给我以下响应:


  此页面包含以下错误:
  
  第40行的第40列的错误:xmlParseCharRef:无效的xmlChar值
  0


下面是直到第一个错误的页面呈现。

840092 10777579 VER 1900-12-31T00:00:00 SYS EMV AKT VIR Arnar Mar Jonsson         Arnar's Bud- og Landbrugscervice 25251628 910673 AKT 2009-10-02T16:21:37 J 2003-    09-18T18:59:40 2399-12-31T00:00:00 N DK 6621 Gesten Gyvelvej 11 0 VIR 2011-11-    05T05:46:03 Arnar's Bud- og Landbrugscervice VIR NKA 2010-06-26T19:12:27 Arnars     Bud- & Landbrugsservice VIR NKA 2010-01-18T06:35:48 Arnar's Bud- og     Landbrugscervice VIR NKA 2009-10-23T06:25:55 Arnar's Bud- og Landbrugscervice v/     Arnar Mar Jonsson VIR NKI 2009-10-05T12:41:28 Arnar'S Bud- og Landbrugscervice V     /Arnar Mar Jonsson VIR NKA 2009-10-05T12:41:28 Arnar'S Bud- og Landbrugscervice     V /Arnar Mar Jonsson v/ Arnar Mar Jon VIR NKI 2004-05-04T15:57:52 Arnar Mar     Jonsson VIR NTI 2004-04-30T17:01:15


它在Internet Explorer中以正确的方式呈现。
IE中形成的XML是:

<?xml version="1.0" encoding="utf-8" ?>
<IdCardSearchResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-    instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"     xmlns="http://experiannordic.com/">
  <IdCardArray>
    <IdCard>
      <IdCardNo>5840092</IdCardNo>
      <ConnectedIdCardNo>10777579</ConnectedIdCardNo>
      <NameProtectionFromDate xsi:nil="true" />
      <VerificationType>VER</VerificationType>
      <VerificationDate>1900-12-31T00:00:00</VerificationDate>
      <VerificationInit>SYS</VerificationInit>
      <IdCardType>EMV</IdCardType>
      <IdCardStatus>AKT</IdCardStatus>
      <DataSource>VIR</DataSource>
      <PersonData>
        <FirstName>Arnar</FirstName>
        <LastName>Mar Jonsson</LastName>
        <DateOfBirth xsi:nil="true" />
        <CprStatusDate xsi:nil="true" />
      </PersonData>
      <CompanyData>
        <CompanyName>Arnar's Bud- og Landbrugscervice</CompanyName>
        <CvrNumber>25251628</CvrNumber>
        <KobNumber>910673</KobNumber>
        <KobStatus>AKT</KobStatus>
        <KobAjourDate>2009-10-02T16:21:37</KobAjourDate>
      </CompanyData>
      <AddressData>
        <CurrentAddress>J</CurrentAddress>
        <AddressFromDate>2003-09-18T18:59:40</AddressFromDate>
        <AddressToDate>2399-12-31T00:00:00</AddressToDate>
        <ForeignAddress>N</ForeignAddress>
        <CountryCode>DK</CountryCode>
        <PostalCode>6621</PostalCode>
        <PostalDistrict>Gesten</PostalDistrict>
        <Street>Gyvelvej</Street>
        <Number>11</Number>
        <NumberTo>0</NumberTo>
        <SourceType>VIR</SourceType>
      </AddressData>
      <DateOfBirth xsi:nil="true" />
      <CompanyName>Arnar's Bud- og Landbrugscervice</CompanyName>
      <Source>VIR</Source>
      <Type>NKA</Type>
    </NameData>
    <NameData>
      <CompanyName>Arnars Bud- & Landbrugsservice</CompanyName>
      <Source>VIR</Source>
      <Type>NKA</Type>
    </NameData>
    <NameData>
      <CompanyName>Arnar's Bud- og Landbrugscervice</CompanyName>
      <CompanyName>Arnar'S Bud- og Landbrugscervice V /Arnar Mar      Jonsson</CompanyName>
      <CompanyName>Arnar'S Bud- og Landbrugscervice V /Arnar Mar Jonsson v/ Arnar Mar Jon</CompanyName>
      <CompanyName>Arnar's Budservice v/ Arnar Mar Jonsson</CompanyName>
      <NameToDate xsi:nil="true" />
      <DateOfBirth xsi:nil="true" />
      <CompanyName>Arnar's Budservice</CompanyName>
      <Source>VIR</Source>
      <Type>NKA</Type>
    </NameData>
      <AddressToDate xsi:nil="true" />
      <ForeignAddress>N</ForeignAddress>
      <CountryCode>DK</CountryCode>
      <PostalCode>6000</PostalCode>
      <PostalDistrict>Kolding</PostalDistrict>
      <Street>Tvedvej</Street>
      <Number>20</Number>
      <NumberTo>0</NumberTo>
      <SourceType>VIR</SourceType>
      </AddressData>
      </AddressArray>
      <IdCardRelationArray>
        <IdCardRelationData>
          <IdCardNumberFrom>5840092</IdCardNumberFrom>
          <RelationType>EMV2PER</RelationType>
          <IdCardNumberTo>10777579</IdCardNumberTo>
          <IdCardRelationDate>2004-08-14T14:18:27</IdCardRelationDate>
          <IdCardRelationChangeDate xsi:nil="true" />
        </IdCardRelationData>
      </IdCardRelationArray>
    </IdCard>
  </IdCardArray>
</IdCardSearchResponse>


为什么此请求中的数据没有显示在Google Chrome中?

最佳答案

不同的浏览器在处理无效XML方面具有不同的解析引擎和差异。在这种情况下,Chrome(正确地)比IE更严格。

要解决此错误,您需要用&amp;替换下一行中的&,这是XML中“&”字符的有效表示形式。

<CompanyName>Arnars Bud- & Landbrugsservice</CompanyName>


应该变成:

<CompanyName>Arnars Bud- &amp; Landbrugsservice</CompanyName>


不幸的是,但是您不能总是相信其他系统的XML输出将正确地形成,因此,某些逻辑来检测或清除它总是谨慎的。

关于c# - xmlParseCharRef:无效的xmlChar值0,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/30216913/

10-09 23:59