title: RestSharp deserialize deeply nested XML document
body: <p>I've been struggling with getting RestSharp to parse the following returned XML data:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;TICKETANYWHERE&gt;
     &lt;COUPON VER="1.0"&gt;
        &lt;RESPONSE&gt;
           &lt;TEMPLATELIST&gt;
              &lt;TEMPLATE ID="000000001"&gt;
                 &lt;NAME&gt;Some name&lt;/NAME&gt;
              &lt;/TEMPLATE&gt;
              &lt;TEMPLATE ID="000000001"&gt;
                 &lt;NAME&gt;Some other name&lt;/NAME&gt;
              &lt;/TEMPLATE&gt;
           &lt;/TEMPLATELIST&gt;
        &lt;/RESPONSE&gt;
     &lt;/COUPON&gt;
  &lt;/TICKETANYWHERE&gt;
  </code></pre>
  
  <p>It's returned from an API, so I have no way to change this XML. I have created the following classes to model the XML file:
  </p>
  
  <pre><code>public class Template
  {
      public string Id { get; set; }
  
      public string Name { get; set; }
  }
  public class TemplateList : List&lt;Template&gt;
  {}
  
  public class Response
  {
      public TemplateList Templates { get; set; }
  }
  public class Coupon
  {
      public decimal Ver { get; set; }
  
      public Response Response { get; set; }
  }
  public class TicketAnywhere
  {
      public Coupon Coupon { get; set; }
  }
  </code></pre>
  
  <p>And then I have created the following unittest (<a href="https://stackoverflow.com/questions/8896911/testing-the-deserialization-of-restsharp-without-proper-rest-api">inspired by</a>)</p>
  
  <pre class="lang-cs prettyprint-override"><code>var d = new XmlDeserializer();
  var response = new RestSharp.RestResponse();
  var XML = "&lt;TICKETANYWHERE&gt;&lt;COUPON VER=\"1.0\"&gt;&lt;RESPONSE&gt;&lt;TEMPLATELIST&gt;&lt;TEMPLATE ID=\"00000001\"&gt;&lt;NAME&gt;Some name&lt;/NAME&gt;&lt;/TEMPLATE&gt;&lt;/TEMPLATELIST&gt;&lt;/RESPONSE&gt;&lt;/COUPON&gt;&lt;/TICKETANYWHERE&gt;";
  response.Content = XML;
  var r = d.Deserialize&lt;TicketAnywhere&gt;(response);
  </code></pre>
  
  <p>However, r.Coupon is NULL. What am I doing wrong here?</p>
  
  <p><strong>UPDATE</strong>:
  I tried to boil down the problem to it's most simple form by changing the XML and the test to the following:</p>
  
  <pre><code>    public class Template
      {
          public string Id { get; set; }
          public string Name { get; set; }
      }
  
      public class TemplateList
      {
          public List&lt;Template&gt; Templates { get; set; }
      }
  
      [Test]
      public void AnotherTest()
      {
          var XML = @"&lt;?xml version=""1.0"" encoding=""UTF-8""?&gt;
          &lt;TEMPLATELIST&gt;
              &lt;TEMPLATE ID=""00000001""&gt;
                  &lt;NAME&gt;Some name&lt;/NAME&gt;
              &lt;/TEMPLATE&gt;
              &lt;TEMPLATE ID=""00000002""&gt;
                  &lt;NAME&gt;Some name&lt;/NAME&gt;
              &lt;/TEMPLATE&gt;
          &lt;/TEMPLATELIST&gt;";
  
          var d = new XmlDeserializer();
          var response = new RestSharp.RestResponse();
          response.Content = XML;
  
          var r = d.Deserialize&lt;TemplateList&gt;(response);
          Assert.That(2, Is.EqualTo(r.Templates.Count));
      }
  </code></pre>
  
  <p>Which again fails. However, if I change the class name from Template => TEMPLATE it all seems to work.</p>