XML 文档(2, 2)中有错误。如何理解这里的(2, 2)?
如何解决这个错误问题?<?xml version="1.0"?>
<T_CTN_Container xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <ContainerCTN>00000000-0000-0000-0000-000000000000</ContainerCTN>
  <VoyageDetail>00000000-0000-0000-0000-000000000000</VoyageDetail>
  <Voyage>00000000-0000-0000-0000-000000000000</Voyage>
  <Vessel>00000000-0000-0000-0000-000000000000</Vessel>
  <Organize>00000000-0000-0000-0000-000000000000</Organize>
  <Sequence>0</Sequence>
  <ContainerNO />
  <SealNO />
  <SizeCTN />
  <TypeCTN />
  <Status />
  <CarryType />
  <Weight>0</Weight>
  <NetWeight>0</NetWeight>
  <CTNWeight>0</CTNWeight>
  <TallyMaster>00000000-0000-0000-0000-000000000000</TallyMaster>
  <TallyClerk>00000000-0000-0000-0000-000000000000</TallyClerk>
  <TallyTime>1900-01-01T00:00:00</TallyTime>
  <ReeferSign>false</ReeferSign>
  <TemperatureSetting />
  <DangerSign>false</DangerSign>
  <DangerClass />
  <OverLack>0</OverLack>
  <DamageSign>false</DamageSign>
  <RestowageSign>false</RestowageSign>
  <Holiday>0</Holiday>
  <Labour>0</Labour>
  <TallyType>0</TallyType>
  <LoadPort />
  <DischargePort />
  <OrderPort />
  <ContainerSort>0</ContainerSort>
  <BayCodePrepare />
  <BayCodeTally />
  <IsUpLoad>false</IsUpLoad>
  <TruckNo />
  <Trade>0</Trade>
  <StockType>0</StockType>
  <StockDescription />
  <Packages>0</Packages>
  <CustomCode />
  <AgencyCode>AB</AgencyCode>
  <ManifestPackages>0</ManifestPackages>
  <WhereCondition> Vessel = '07f476a6-6edd-40b6-8e1b-95ed4e381cf4' And Voyage = 'a476561a-c250-472d-8275-d17098c91f68' And VoyageDetail = 'd20ef27f-e213-4c7d-8f99-9f2c85c8491d' And Organize = '6d809ca9-fe49-443c-b120-0809742ef069'</WhereCondition>
  <OrderByExpression />
  <OldVoyageDetail>00000000-0000-0000-0000-000000000000</OldVoyageDetail>
  <OldVoyage>00000000-0000-0000-0000-000000000000</OldVoyage>
  <OldVessel>00000000-0000-0000-0000-000000000000</OldVessel>
  <OldOrganize>00000000-0000-0000-0000-000000000000</OldOrganize>
  <TotalRowCount>0</TotalRowCount>
  <IsMainCell>false</IsMainCell>
  <FillStatus>0</FillStatus>
</T_CTN_Container>

解决方案 »

  1.   

    http://topic.csdn.net/u/20090116/09/6703d9cb-e0a5-4d6e-9630-3367ba8cc441.html
      

  2.   

    原则上应该不是XML的问题, 这段XML可以正常解析.
    检查一下代码.
      

  3.   

    代码反系列化其它的XML都没有问题的

    [WebMethod]
    public bool pro_T_CTN_Container_Select(byte[] pEBT, ref byte[] pDSBT)
    {
        try
        {
            bool mReturn = false;        string mConnectionString = System.Configuration.ConfigurationManager.AppSettings["ConnectionStrings"].ToString();        Entity.T_CTN_Container mEntity = (Entity.T_CTN_Container)Data.CommonFunction.EntityDeserialize(pEBT, typeof(Entity.T_CTN_Container));        mReturn = Data.T_CTN_Container.pro_T_CTN_Container_Select(mEntity, ref mDS, mConnectionString);        pDSBT = Data.CommonFunction.DataSetSerialize(mDS);        return mReturn;
        }
        catch (NullReferenceException NullEx)
        {
            mMSG = NullEx.Message;
            return false;
        }
        catch (Exception Ex)
        {
            mMSG = Ex.Message;
            return false;
        }
    }public static object EntityDeserialize(byte[] pBT, System.Type pType)
    {
        try
        {
            System.Xml.Serialization.XmlSerializer mySerializer = new System.Xml.Serialization.XmlSerializer(pType);
            System.IO.MemoryStream unMS = new System.IO.MemoryStream();        unMS.Write(pBT, 0, pBT.Length);
            unMS.Seek(0, System.IO.SeekOrigin.Begin);        return mySerializer.Deserialize(unMS);   //这里出错
        }
        catch (NullReferenceException NullEx)
        {
            throw NullEx;
        }
        catch (Exception Ex)
        {
            throw Ex;
        }
    }
      

  4.   

    xml内容就是从pBT字节数组中转换过来的
      

  5.   

    字符编码格式是否正确,设置一下encoding试一试,有时候因为编码格式不一致会导至出错
      

  6.   

    不清楚在哪里设置encoding
      

  7.   

    改成这样<?xml version="1.0" encoding="utf-8" ?> 
    <T_CTN_Container>
    ......
    </T_CTN_Container>
      

  8.   

    从XML来看,是正确的看到你使用了webservice请问你客户端和WebService的Entity.T_CTN_Container 是否一致?这个问题很重要
      

  9.   

    在IE下直接浏览这个xml,IE会告诉你哪儿出错了
      

  10.   

    <?xml version="1.0" encoding="utf-8" ?> 
      

  11.   

    WebService中的Entity.T_CTN_Container 为了写默认值,调用了
    private string m_strCustomCode = System.Configuration.ConfigurationManager.AppSettings["DeclarationOfficeID"].ToString();Client没有调用因此有问题
      

  12.   

    1.检查  encoding="utf-8"
    2.检查  xmlns 命名空间
    3.检查  xml的名称,是否与XSD里的类型名称重复
      

  13.   

    我碰到过的,解决了----------        我碰到的情况是:在对实体类进行序列化和反序列化时,如果 [XmlRoot("aaa")]
                          与需要序列化的类名或者结构名不一样时。
             会出现:System.InvalidOperationException: XML 文档(2, 2)中有错误。
             见下面:
           [XmlRoot("aaa")]
            public struct aaa
            {
                public string Code;
                public string Name;
            }
           
            即:[XmlRoot("aaa")]中的值要和要和序列化/反序列化中的类或者结构的名称一样!