title: C# Xml Deserialize collection with nested collection, nested collection is null
body: <p>I am consuming a third party API. I am trying to deserialize an XML string into C# complex classes. This xml string contains an array with a nested array. I am successful in serializing to the outer List (&quot;Description&quot;), but the nested List is null (&quot;Item&quot;). I am not sure what the issue is.</p>
  <pre><code>   &lt;data boardid=&quot;abcdefg&quot; listingid=&quot;23232323&quot;&gt;
          &lt;description&gt;
            &lt;group name=&quot;Address&quot;&gt;
              &lt;item displayname=&quot;Address&quot; displayvalue=&quot;123 W Apple Ave&quot; standardname=&quot;ad_street_address&quot; /&gt;
              &lt;item displayname=&quot;Address Direction&quot; displayvalue=&quot;W&quot; standardname=&quot;ad_street_direction&quot; /&gt;
              ...            
            &lt;/group&gt;
            &lt;group name=&quot;Agent/Office&quot;&gt;
              &lt;item displayname=&quot;Agent First Name&quot; displayvalue=&quot;John&quot; standardname=&quot;ag_name_first&quot; /&gt;
              &lt;item displayname=&quot;Agent Last Name&quot; displayvalue=&quot;Dor&quot; standardname=&quot;ag_name_last&quot; /&gt;
              ...
            &lt;/group&gt;
            ...
          &lt;/description&gt;
      &lt;/data&gt;
  </code></pre>
  <p>C# Class Objects:</p>
  <pre><code>    [Serializable]
      [XmlRoot(&quot;item&quot;)]
      public class Item
      {
          [XmlAttribute(&quot;displayname&quot;)]
          public string displayname { get; set; }
          [XmlAttribute(&quot;displayvalue&quot;)]
          public string displayvalue { get; set; }
          [XmlAttribute(&quot;standardname&quot;)]
          public string standardname { get; set; }
      }
      
      [Serializable()]         
      [XmlRoot(&quot;group&quot;)]
      public class Group
      {
          [XmlAttribute]
          public string name { get; set; }
          
          [XmlArray(&quot;group&quot;)]
          [XmlArrayItem(&quot;item&quot;)]
          public List&lt;Item&gt; item { get; set; } // this is null
      }
      
      [Serializable]
      [XmlRoot(&quot;data&quot;)]
      public class Data
      {
          
          [XmlAttribute]
          public string boardid { get; set; }
          [XmlAttribute]
          public string listingid  { get; set; }
          [XmlAttribute]
          public string ExternalId { get; set; }
          [XmlArray(&quot;description&quot;)]
          [XmlArrayItem(&quot;group&quot;)]
          public List&lt;Group&gt; description { get; set; } = new List&lt;Group&gt;();
  
      }
  </code></pre>
  <p>Edit: As per accepted answer, the solution was to change the Group class to this:</p>
  <pre><code>    [Serializable()]         
      [XmlRoot(&quot;group&quot;)]
      public class Group
      {
          [XmlAttribute]
          public string name { get; set; }
          
          [XmlElement(&quot;item&quot;)]
          public List&lt;Item&gt; item { get; set; }
      }
  </code></pre>