title: How to Deserialize XML in c# having child nodes of same type
body: <p>I need to deserialize bellow XML. The chapter element can have multiple child chapter element in it.I have tried to deserialize the XML using XmlSerializer.
  All the elements are deserializing as expected but the issue is that the child Chapter array is not deserializing, am I missing something here? Please help.</p>
  
  <pre><code>&lt;Survey&gt;
          &lt;SurveyResults&gt;
              &lt;Subject&gt;
                  &lt;Chapter&gt;
                      &lt;ChapterIterationName /&gt;
                      &lt;Questions /&gt;
                      &lt;Chapter&gt;
                          &lt;ChapterName&gt;CHAPTER 1&lt;/ChapterName&gt;
                          &lt;ChapterIterationName /&gt;
                          &lt;Questions&gt;
                              &lt;Question&gt;
                                  &lt;Text&gt;Question 1&lt;/Text&gt;
                              &lt;/Question&gt;
                              &lt;Question&gt;
                                  &lt;Text&gt;Question 2&lt;/Text&gt;
                              &lt;/Question&gt;
                          &lt;/Questions&gt;
                          &lt;Chapter&gt;
                              &lt;ChapterName&gt;CHAPTER 1.1&lt;/ChapterName&gt;
                              &lt;ChapterIterationName /&gt;
                              &lt;Questions&gt;
                                  &lt;Question&gt;
                                      &lt;Text&gt;Questoin 1&lt;/Text&gt;
                                  &lt;/Question&gt;
                                  &lt;Question&gt;
                                      &lt;Text&gt;Questoin 2&lt;/Text&gt;
                                  &lt;/Question&gt;
                              &lt;/Questions&gt;
                          &lt;/Chapter&gt;
                          &lt;Chapter&gt;
                              &lt;ChapterName&gt;CHAPTER 1.2&lt;/ChapterName&gt;
                              &lt;ChapterIterationName /&gt;
                              &lt;Questions&gt;
                                  &lt;Question&gt;
                                      &lt;Text&gt;Questoin 1&lt;/Text&gt;
                                  &lt;/Question&gt;
                                  &lt;Question&gt;
                                      &lt;Text&gt;Questoin 2&lt;/Text&gt;
                                  &lt;/Question&gt;
                              &lt;/Questions&gt;
                          &lt;/Chapter&gt;
                      &lt;/Chapter&gt;
                  &lt;/Chapter&gt;
              &lt;/Subject&gt;
          &lt;/SurveyResults&gt;
      &lt;/Survey&gt;
  </code></pre>
  
  <p>Here is the code I have tried. </p>
  
  <pre><code>public class Survey
      { 
          public SurveyResults SurveyResults { get; set; }
      }
  
      public class SurveyResults
      {
          public Subject Subject { get; set; }
      }
  
      public class Subject
      { 
          public List&lt;Chapter&gt; Chapter { get; set; }
      }
  
      public class Chapter
      {
          public string ChapterName { get; set; }
          public string ChapterIterationName { get; set; }
  
          [XmlArray("Chapter")]
          public List&lt;Chapter&gt; Chapters { get; set; }
          public List&lt;Questions&gt; Questions { get; set; }
      }
  
      public class Questions
      {
           public List&lt;Question&gt; Question { get; set; }
      }
  
      public class Question
      {
          public string Text { get; set; } 
      }
  
      public class Serializer
      { 
          public T Deserialize&lt;T&gt;(string input) where T : class
          {
              System.Xml.Serialization.XmlSerializer ser = new System.Xml.Serialization.XmlSerializer(typeof(T));
  
              using (StringReader sr = new StringReader(input))
              {
                  return (T)ser.Deserialize(sr);
              }
          }
      }
  
      Serializer ser = new Serializer();
      Survey survey = ser.Deserialize&lt;Survey&gt;(xlString);
  </code></pre>
  
  <p>Result 
  <a href="https://i.stack.imgur.com/R9uze.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/R9uze.png" alt="Output"></a></p>