title: Error deserializing xml web response
body: <p>I am trying to deserialize a "SearchRecordList" class using the DataContractSerializer and keep getting the exception:</p>
  
  <pre><code>System.InvalidOperationException: No corresponding start element is open.
  </code></pre>
  
  <p>The XML i am receiving looks like this:</p>
  
  <pre><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;&lt;records type=\"array\" count=\"0\"/&gt;
  </code></pre>
  
  <p>What is strange, is that if i run a test, and pass this XML string:</p>
  
  <pre><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;&lt;records type=\"array\" count=\"0\"&gt;&lt;/records&gt;
  </code></pre>
  
  <p>It works fine.  Any ideas what I am doing wrong?  Below is the class I am deserializing to (C#, .NET 4.0):</p>
  
  <pre><code> [XmlRoot(Namespace = "", ElementName = "records", DataType = "array")]
  public class SearchRecordList:List&lt;SearchRecord&gt;, IXmlSerializable
  {
  
      #region IXmlSerializable Members
  
      public System.Xml.Schema.XmlSchema GetSchema()
      {
          return null;
      }
  
      public void ReadXml(System.Xml.XmlReader reader)
      {
          var navigator = reader.CreateNavigator(); //returns an XPathNavigator based on the reader.
          var root = navigator.SelectSingleNode("records");
  
          int count;
  
          if (!int.TryParse(root.GetAttribute("count", ""), out count) || count &lt; 1)
              return;
  
          navigator.MoveToFirstChild();
  
          var n = navigator.Select("record");
  
          AddRange(n.ToList&lt;SearchRecord&gt;());
      }
  
      public void WriteXml(System.Xml.XmlWriter writer)
      {
          throw new System.NotImplementedException();
      }
  
      #endregion
  }
  </code></pre>