title: Deserialize XML to list of lists
body: <p>Given the following code used to serialize:</p>
  
  <pre><code>[XmlRoot(Namespace = "", IsNullable = true, ElementName = "ReportSpec")]
  [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]
  public partial class ReportSpec{
      [System.Xml.Serialization.XmlElementAttribute("Reports")]
      public ReportsHolder MyHolder { get; set; }
  
      [System.Xml.Serialization.XmlAttributeAttribute()]
      public decimal Version { get; set; }
  
      [System.Xml.Serialization.XmlAttributeAttribute()]
      public string Username { get; set; }
  }
  
  public partial class ReportsHolder{
      [System.Xml.Serialization.XmlElement(IsNullable = true)]
      public List&lt;AlertsReport&gt; AlertsReportList { get; set; }
  
      [System.Xml.Serialization.XmlElement(IsNullable = true)]
      public List&lt;DeviceHistoryReport&gt; DeviceHistoryReportList { get; set; }
  
      public ReportsHolder(){
          this.AlertsReportList = new List&lt;AlertsReport&gt;();
          this.DeviceHistoryReport = new List&lt;DeviceHistoryReport&gt;();
      }
  }
  
  public abstract class BaseReport{
      [System.Xml.Serialization.XmlAttributeAttribute()]
      public string ReportName { get; set; }
  
      [System.Xml.Serialization.XmlAttributeAttribute()]
      public string FilterMode { get; set; }
  
      [System.Xml.Serialization.XmlAttributeAttribute()]
      public string Destination { get; set; }
  
      [System.Xml.Serialization.XmlAttributeAttribute()]
      public string Format { get; set; }
  }
  
  [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]
  public partial class AlertsReport : BaseReport{
  
      public AlertsReportFilters Filters { get; set; }
  
      public AlertsReport(){
          Filters = new AlertsReportFilters();
      }
  }
  
  [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]
  public partial class AlertsReportFilters{
  
      public string AlertSource { get; set; }
  
      public byte? Scope { get; set; }
  
      public bool ShouldSerializeScope(){
          return Scope != null;
      }
  
      public ushort? DeviceID { get; set; }
  
      public bool ShouldSerializeDeviceID(){
          return DeviceID != null;
      }
  
      public string DeviceType { get; set; }
  
      public byte? DeviceGroup { get; set; }
  
      public bool ShouldSerializeDeviceGroup(){
          return DeviceGroup != null;
      }
  
      public uint? DeviceFacility { get; set; }
  
      public bool ShouldSerializeDeviceFacility(){
          return DeviceFacility != null;
      }
  
      public uint? DeviceRegion { get; set; }
  
      public bool ShouldSerializeDeviceRegion(){
          return DeviceRegion != null;
      }
  }
  
  [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]
  public partial class DeviceHistoryReport : BaseReport{
  
      public ushort? DeviceID { get; set; }
  
      public bool ShouldSerializeDeviceID(){
          return DeviceID != null;
      }
  }
  </code></pre>
  
  <p>Which ends up serializing like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;ReportSpec Version="4.5" Username="My Name"&gt;
    &lt;Reports&gt;
      &lt;AlertsReportList FilterMode="Container" Destination="someone@somewhere.com" Format="PDF"&gt;
        &lt;Filters&gt;
          &lt;AlertSource&gt;Frankenstein&lt;/AlertSource&gt;
          &lt;Scope&gt;0&lt;/Scope&gt;
        &lt;/Filters&gt;
      &lt;/AlertsReportList&gt;
  
      &lt;AlertsReportList FilterMode="Container" Destination="someone.else@somewhere.com" Format="XLS"&gt;
        &lt;Filters&gt;
          &lt;DeviceGroup&gt;12&lt;/DeviceGroup&gt;
        &lt;/Filters&gt;
      &lt;/AlertsReportList&gt;
  
      &lt;DeviceHistoryReportList FilterMode="Container" Destination="\\path\on\my\network" Format="DOC"&gt;
        &lt;Filters&gt;
          &lt;DeviceID&gt;255&lt;/DeviceID&gt;
        &lt;/Filters&gt;
      &lt;/DeviceHistoryReportList&gt;
  
      &lt;DeviceHistoryReportList FilterMode="Container" Destination="mr.executive@somewhere.com" Format="TXT"&gt;
        &lt;Filters&gt;
          &lt;DeviceID&gt;44&lt;/DeviceID&gt;
        &lt;/Filters&gt;
      &lt;/DeviceHistoryReportList&gt;
    &lt;/Reports&gt;
  &lt;/ReportSpec&gt;
  </code></pre>
  
  <p>I am wanting to get a list of each ReportList object to process later in my application, but I am getting a "Type 'ReportSpec' is not enumerable" error in my foreach loop:</p>
  
  <pre><code>var streamReader = new StreamReader(@"C:\temp\TestFile.xml");
  TextReader reader = streamReader;
  var xmlSerializer = new XmlSerializer(typeof(ReportSpec));
  var list = (ReportSpec)xmlSerializer.Deserialize(reader);
  foreach (var report in list){    // &lt;-- error is here
      //re-direct the report (AlertsReportList, DeviceHistoryReportList) for processing
  }
  </code></pre>
  
  <p>Is what I want even possible, and if so, where am I screwing up?</p>