title: Cannot deserialize from XML
body: <p>I have a fixed, valid XML document. I'm trying to deserialize it in order to get an object hierarchy. However there's an exception being thrown.</p>
  
  <p>This is my XML document:</p>
  
  <pre><code>&lt;ROWSET&gt;
     &lt;ROW&gt;
        &lt;LOT&gt;LOT1234&lt;/LOT&gt;
        &lt;DATE_TRANS&gt;2012-05-20&lt;/DATE_TRANS&gt;
        &lt;NUMERO_AA227&gt;AA227_001&lt;/NUMERO_AA227&gt;
        &lt;NUMERO_ETUI&gt;ETUI_001&lt;/NUMERO_ETUI&gt;   
        &lt;IDENTITE_BOITE_1&gt;Boite1_1&lt;/IDENTITE_BOITE_1&gt;
        &lt;IDENTITE_BOITE_2&gt;Boite1_2&lt;/IDENTITE_BOITE_2&gt;
        &lt;IDENTITE_BOITE_3&gt;Boite1_3&lt;/IDENTITE_BOITE_3&gt;
        &lt;IDENTITE_BOITE_4&gt;Boite1_5&lt;/IDENTITE_BOITE_4&gt;
        &lt;IDENTITE_BOITE_5&gt;Boite1_5&lt;/IDENTITE_BOITE_5&gt;
     &lt;/ROW&gt;
     &lt;ROW&gt;
        &lt;LOT&gt;LOT5678&lt;/LOT&gt;
        &lt;DATE_TRANS&gt;2012-05-20&lt;/DATE_TRANS&gt;
        &lt;NUMERO_AA227&gt;AA227_001&lt;/NUMERO_AA227&gt;
        &lt;NUMERO_ETUI&gt;ETUI_001&lt;/NUMERO_ETUI&gt;   
        &lt;IDENTITE_BOITE_1&gt;Boite1_1&lt;/IDENTITE_BOITE_1&gt;
        &lt;IDENTITE_BOITE_2&gt;Boite1_2&lt;/IDENTITE_BOITE_2&gt;
        &lt;IDENTITE_BOITE_3&gt;Boite1_3&lt;/IDENTITE_BOITE_3&gt;
        &lt;IDENTITE_BOITE_4&gt;Boite1_5&lt;/IDENTITE_BOITE_4&gt;
        &lt;IDENTITE_BOITE_5&gt;Boite1_5&lt;/IDENTITE_BOITE_5&gt;
     &lt;/ROW&gt;
  &lt;/ROWSET&gt;
  </code></pre>
  
  <p>And this is my object model:</p>
  
  <pre><code>[Serializable]
  [System.Xml.Serialization.XmlRoot("DTOFournitureListeImporter")]
  public class DTOFournitureListeImporter
  {
     [XmlArray("ROWSET")]
     [XmlArrayItem("ROW", typeof(DTOFournitureImporter))]
     public DTOFournitureImporter[] dtoFournitureImporter { get; set; }
  }
  
  [Serializable]
  public class DTOFournitureImporter
  {
     [System.Xml.Serialization.XmlElement("lot")]
     public string lot { get; set; }
  
     [System.Xml.Serialization.XmlElement("date_trans")]
     public DateTime date_trans { get; set; }
  
     [System.Xml.Serialization.XmlElement("numero_aa227")]
     public string numero_aa227 { get; set; }
  
     [System.Xml.Serialization.XmlElement("numero_etui")]
     public string numero_etui { get; set; }
  
     [System.Xml.Serialization.XmlElement("identite_boite_1")]
     public string identite_boite_1 { get; set; }
  
     [System.Xml.Serialization.XmlElement("identite_boite_2")]
     public string identite_boite_2 { get; set; }
  
     [System.Xml.Serialization.XmlElement("identite_boite_3")]
     public string identite_boite_3 { get; set; }
  
     [System.Xml.Serialization.XmlElement("identite_boite_4")]
     public string identite_boite_4 { get; set; }
  
     [System.Xml.Serialization.XmlElement("identite_boite_5")]
     public string identite_boite_5 { get; set; }
  }
  </code></pre>
  
  <p>How I deserialize:</p>
  
  <pre><code>XmlSerializer serializer = new XmlSerializer(typeof(DTOFournitureListeImporter));
  TextReader textReader = new StreamReader(model.cheminFichierXML);
  DTOFournitureListeImporter dTOFournitureListeImporter = (DTOFournitureListeImporter)serializer.Deserialize(textReader);
  textReader.Close();
  </code></pre>
  
  <p>And the error:</p>
  
  <blockquote>
    <p>There is an error in XML document (2, 2). -
    System.InvalidOperationException: was not expected.
    Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderDTOFournitureListeImporter.Read4_DTOFournitureListeImporter()</p>
  </blockquote>