title: Deserialize XML to Object Array
body: <p>I'm trying to deserialize an XML file to an object array, but I'm receiving empty objects.
  My question looks similar to this: <a href="https://stackoverflow.com/questions/7541899/how-to-deserialize-xml-to-an-array-of-objects">How to Deserialize xml to an array of objects?</a> but I can't seem to create a class which inherits IXmlSerializable. That said, I don't think that approach is necessary. </p>
  
  <p>Am I doing something wrong?</p>
  
  <p><strong>File Object</strong>   </p>
  
  <pre><code> [XmlType("file")]
      public class File
      {
          [XmlElement("id")]
          public string Id { get; set; }
  
          [XmlElement("company_name")]
          public string Company_Name { get; set; }
  
          [XmlElement("docs")]
          public HashSet&lt;doc&gt; Docs { get; set; }
      }
  </code></pre>
  
  <p><strong>Doc Object</strong> </p>
  
  <pre><code> [XmlType("doc")]
      public class Doc
      {
          [XmlElement("valA")]
          public string ValA { get; set; }
  
          [XmlElement("valB")]
          public string ValB { get; set; }
      }
  </code></pre>
  
  <p><strong>XML</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
    &lt;files&gt;
      &lt;file&gt;
        &lt;id&gt;12345&lt;/id&gt;
        &lt;company_name&gt;Apple&lt;/company_name&gt;
        &lt;docs&gt;
         &lt;doc&gt;
            &lt;valA&gt;Info&lt;/valA&gt;
            &lt;valB&gt;More Info&lt;/valB&gt;
         &lt;/doc&gt;  
        &lt;/docs&gt;
      &lt;/file&gt;
      &lt;file&gt;
        &lt;id&gt;12345&lt;/id&gt;
        &lt;company_name&gt;Microsoft&lt;/company_name&gt;
        &lt;docs&gt;
         &lt;doc&gt;
            &lt;valA&gt;Even More Info&lt;/valA&gt;
            &lt;valB&gt;Lots of it&lt;/valB&gt;
         &lt;/doc&gt;  
        &lt;/docs&gt;
      &lt;/file&gt;
    &lt;/files&gt;
  </code></pre>
  
  <p><strong>Deserialization code</strong></p>
  
  <pre><code>XmlSerializer mySerializer = new XmlSerializer(typeof(File[]), new XmlRootAttribute("files"));
  using (FileStream myFileStream = new FileStream("Files.xml", FileMode.Open))
  {
      File[] r;
      r = (File[])mySerializer.Deserialize(myFileStream);
  }
  </code></pre>