title: XML Deserialization of DataTable or DataSet
body: <p>I have the following XML:</p>
  
  <pre><code>     &lt;NewDataSet&gt;
          &lt;xs:schema id="NewDataSet" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"&gt;
            &lt;xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:MainDataTable="Data" msdata:UseCurrentLocale="true"&gt;
              &lt;xs:complexType&gt;
                &lt;xs:choice minOccurs="0" maxOccurs="unbounded"&gt;
                  &lt;xs:element name="Data"&gt;
                    &lt;xs:complexType&gt;
                      &lt;xs:sequence&gt;
                      &lt;/xs:sequence&gt;
                    &lt;/xs:complexType&gt;
                  &lt;/xs:element&gt;
                &lt;/xs:choice&gt;
              &lt;/xs:complexType&gt;
            &lt;/xs:element&gt;
          &lt;/xs:schema&gt;
       &lt;/NewDataSet&gt;
  </code></pre>
  
  <p>I know this was created by serializing a DataTable with <code>new XmlSerializer(typeof(DataTable)).Serialize(writer, (DataTable)myDataTable);</code>.</p>
  
  <p>The schema as well as the actual data can be different in them.</p>
  
  <p>I need to deserialize it, and tried the following:</p>
  
  <pre><code>reader.ReadStartElement("NewDataSet");
  var dataSet = (DataTable)new XmlSerializer(typeof(DataTable)).Deserialize(reader);
  reader.ReadEndElement();
  </code></pre>
  
  <p>and also:</p>
  
  <pre><code>reader.ReadStartElement("NewDataSet");
  var dataSet = (DataSet)new XmlSerializer(typeof(DataSet)).Deserialize(reader);
  reader.ReadEndElement();
  </code></pre>
  
  <p>All I got was</p>
  
  <blockquote>
    <p>System.InvalidOperationException was unhandled
      Message=There is an error in XML document (26, 14).
      Source=System.Xml</p>
  </blockquote>
  
  <p>InnerException:</p>
  
  <blockquote>
    <p>"http://www.w3.org/2001/XMLSchema'> was not expected."</p>
  </blockquote>
  
  <p><strong>How can I deserialize that thing?</strong></p>