-1

以下代码引发 XML 反序列化错误 (20,2),我不知道为什么。XmlSerialiser 是否有一些特殊的东西需要了解数据集的反序列化?

Dim strStringReader As StringReader = New StringReader(strValue)
Dim oXS As XmlSerializer = New XmlSerializer(strObjectType)
Deserialize = oXS.Deserialize(strStringReader)

这是 xml(在字符串 strValue 中可用):

<?xml version='1.0' encoding='utf-16'?>
<DataTable>
<xs:schema id='DocumentElement' xmlns='' xmlns:xs='http://www.w3.org/2001/XMLSchema' xmlns:msdata='urn:schemas-microsoft-com:xml-msdata'>
  <xs:element name='DocumentElement' msdata:IsDataSet='true' msdata:UseCurrentLocale='true'>
    <xs:complexType>
      <xs:choice minOccurs='0' maxOccurs='unbounded'>
        <xs:element name='tblCategoryLanguageElements'>
          <xs:complexType>
            <xs:sequence>
              <xs:element name='_LE_LanguageID' type='xs:string' minOccurs='0' />
              <xs:element name='_LE_FieldID' type='xs:string' minOccurs='0' />
              <xs:element name='_LE_Value' type='xs:string' minOccurs='0' />
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:choice>
    </xs:complexType>
  </xs:element>
</xs:schema>
<diffgr:diffgram xmlns:msdata='urn:schemas-microsoft-com:xml-msdata' xmlns:diffgr='urn:schemas-microsoft-com:xml-diffgram-v1'>
  <DocumentElement>
    <tblCategoryLanguageElements diffgr:id='tblCategoryLanguageElements1' msdata:rowOrder='0' diffgr:hasChanges='inserted'>
      <_LE_LanguageID>1</_LE_LanguageID>
      <_LE_FieldID>1</_LE_FieldID>
      <_LE_Value>Components</_LE_Value>
    </tblCategoryLanguageElements>
    <tblCategoryLanguageElements diffgr:id='tblCategoryLanguageElements2' msdata:rowOrder='1' diffgr:hasChanges='inserted'>
      <_LE_LanguageID>1</_LE_LanguageID>
      <_LE_FieldID>2</_LE_FieldID>
      <_LE_Value>Imported by OT2KARTRISSync</_LE_Value>
    </tblCategoryLanguageElements>
    <tblCategoryLanguageElements diffgr:id='tblCategoryLanguageElements3' msdata:rowOrder='2' diffgr:hasChanges='inserted'>
      <_LE_LanguageID>1</_LE_LanguageID>
      <_LE_FieldID>3</_LE_FieldID>
      <_LE_Value />
    </tblCategoryLanguageElements>
    <tblCategoryLanguageElements diffgr:id='tblCategoryLanguageElements4' msdata:rowOrder='3' diffgr:hasChanges='inserted'>
      <_LE_LanguageID>1</_LE_LanguageID>
      <_LE_FieldID>4</_LE_FieldID>
      <_LE_Value />
    </tblCategoryLanguageElements>
    <tblCategoryLanguageElements diffgr:id='tblCategoryLanguageElements5' msdata:rowOrder='4' diffgr:hasChanges='inserted'>
      <_LE_LanguageID>1</_LE_LanguageID>
      <_LE_FieldID>5</_LE_FieldID>
      <_LE_Value />
    </tblCategoryLanguageElements>
    <tblCategoryLanguageElements diffgr:id='tblCategoryLanguageElements6' msdata:rowOrder='5' diffgr:hasChanges='inserted'>
      <_LE_LanguageID>1</_LE_LanguageID>
      <_LE_FieldID>8</_LE_FieldID>
      <_LE_Value />
    </tblCategoryLanguageElements>
  </DocumentElement>
</diffgr:diffgram>
</DataTable>

位置 (20,2) 是这样的:

<diffgr:diffgram xmlns:msdata='urn:sche...

任何帮助表示赞赏!

MadMaxApp

4

1 回答 1

2

对于 DataSets 和 DataTables,有特殊的方法来写入读取Xml。DataSets 和 DataTables 可以通过多种方式进行序列化,因此存在一些重载。从您在问题中显示的 XML 中,我怀疑调用者将 DataTable 的DiffGram发送到您的 Web 服务,这是一种特殊格式,其中包含对 DataSet 或 DataTable 中的数据所做的更改。您可以使用ReadXml重载
之一读取 DiffGram 。

于 2013-11-08T12:38:19.970 回答