Question

The following Code throws an XML deserialisation error (20,2) and i don't know why. Is there somethign special with XmlSerialiser to know for deserialisation of DataSets?

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

this is the xml (available in a string 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>

The Position (20,2) is this:

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

Any help appreciated !!

MadMaxApp

Was it helpful?

Solution

For DataSets and DataTables, there are special methods to write and read Xml. DataSets and DataTables can be serialized in a number of ways, so there are some overloads. From the XML you show in your question, I suspect that the caller sends a DiffGram of a DataTable to your webservice, a special format that contains the changes that have been made to the data in the DataSet or DataTable.
You can read the DiffGram using one of the ReadXml overloads.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top