title: Deserializing with c# unsuccessful
body: <p>I am trying to deserialize this xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;query xmlns:yahoo="http://www.yahooapis.com/v1/base.rng"
  yahoo:count="10" yahoo:created="2012-02-20T19:07:02Z" yahoo:lang="en-US"&gt;
  &lt;results&gt;
      &lt;a href="/dir/index?sid=396545299"&gt;Books &amp;amp; Authors&lt;/a&gt;
      &lt;a href="/dir/index?sid=396545374"&gt;Dancing&lt;/a&gt;
      &lt;a href="/dir/index?sid=396546034"&gt;Genealogy&lt;/a&gt;
      &lt;a href="/dir/index?sid=396545298"&gt;History&lt;/a&gt;
      &lt;a href="/dir/index?sid=396545310"&gt;Other - Arts &amp;amp; Humanities&lt;/a&gt;
      &lt;a href="/dir/index?sid=396545300"&gt;Performing Arts&lt;/a&gt;
      &lt;a href="/dir/index?sid=396545231"&gt;Philosophy&lt;/a&gt;
      &lt;a href="/dir/index?sid=2115500137"&gt;Poetry&lt;/a&gt;
      &lt;a href="/dir/index?sid=396546419"&gt;Theater &amp;amp; Acting&lt;/a&gt;
      &lt;a href="/dir/index?sid=396545309"&gt;Visual Arts&lt;/a&gt;
  &lt;/results&gt;
  &lt;/query&gt;
  </code></pre>
  
  <p>This is by the way a xml that yahoo api returnes when queried for categories and subcategories.</p>
  
  <p>This code that is supposed to deserialize it:</p>
  
  <pre><code>string query_string = "some_url";
  
          HttpWebRequest request = HttpWebRequest.Create
              (query_string) as HttpWebRequest;
  
          using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
          {
              StreamReader reader = new StreamReader(response.GetResponseStream());
  
              System.Xml.Serialization.XmlSerializer serializer = new 
  
              System.Xml.Serialization.XmlSerializer(typeof(queryA));
  
              queryA Q = (queryA)serializer.Deserialize(reader); // THIS IS WHERE THE EXCEPTION IS THROWN
  
              reader.Close();
          }
  </code></pre>
  
  <p>and I get an exception saying: <strong>There is an error in XML document (2, 2)</strong>.</p>
  
  <p><strong><em>Exception details:</em></strong></p>
  
  <pre><code>"&lt;query xmlns=''&gt; was not expected."
  </code></pre>
  
  <p>Here's the class:</p>
  
  <pre><code>namespace Yahoo_answers_tool {
  using System.Xml.Serialization;
  
  
  /// &lt;remarks/&gt;
  [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")]
  [System.SerializableAttribute()]
  [System.Diagnostics.DebuggerStepThroughAttribute()]
  [System.ComponentModel.DesignerCategoryAttribute("code")]
  [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
  [System.Xml.Serialization.XmlRootAttribute(Namespace="", IsNullable=false)]
  public partial class queryA {
  
      private queryResultsA[] resultsField;
  
      private string countField;
  
      private string createdField;
  
      private string langField;
  
      /// &lt;remarks/&gt;
      [System.Xml.Serialization.XmlArrayAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
      [System.Xml.Serialization.XmlArrayItemAttribute("a", typeof(queryResultsA), Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
      public queryResultsA[] results {
          get {
              return this.resultsField;
          }
          set {
              this.resultsField = value;
          }
      }
  
      /// &lt;remarks/&gt;
      [System.Xml.Serialization.XmlAttributeAttribute(Form=System.Xml.Schema.XmlSchemaForm.Qualified, Namespace="http://www.yahooapis.com/v1/base.rng")]
      public string count {
          get {
              return this.countField;
          }
          set {
              this.countField = value;
          }
      }
  
      /// &lt;remarks/&gt;
      [System.Xml.Serialization.XmlAttributeAttribute(Form=System.Xml.Schema.XmlSchemaForm.Qualified, Namespace="http://www.yahooapis.com/v1/base.rng")]
      public string created {
          get {
              return this.createdField;
          }
          set {
              this.createdField = value;
          }
      }
  
      /// &lt;remarks/&gt;
      [System.Xml.Serialization.XmlAttributeAttribute(Form=System.Xml.Schema.XmlSchemaForm.Qualified, Namespace="http://www.yahooapis.com/v1/base.rng")]
      public string lang {
          get {
              return this.langField;
          }
          set {
              this.langField = value;
          }
      }
  }
  
  /// &lt;remarks/&gt;
  [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")]
  [System.SerializableAttribute()]
  [System.Diagnostics.DebuggerStepThroughAttribute()]
  [System.ComponentModel.DesignerCategoryAttribute("code")]
  [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
  public partial class queryResultsA {
  
      private string hrefField;
  
      private string valueField;
  
      /// &lt;remarks/&gt;
      [System.Xml.Serialization.XmlAttributeAttribute()]
      public string href {
          get {
              return this.hrefField;
          }
          set {
              this.hrefField = value;
          }
      }
  
      /// &lt;remarks/&gt;
      [System.Xml.Serialization.XmlTextAttribute()]
      public string Value {
          get {
              return this.valueField;
          }
          set {
              this.valueField = value;
          }
      }
  }
  
  /// &lt;remarks/&gt;
  [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")]
  [System.SerializableAttribute()]
  [System.Diagnostics.DebuggerStepThroughAttribute()]
  [System.ComponentModel.DesignerCategoryAttribute("code")]
  [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
  [System.Xml.Serialization.XmlRootAttribute(Namespace="", IsNullable=false)]
  public partial class NewDataSetA {
  
      private queryA[] itemsField;
  
      /// &lt;remarks/&gt;
      [System.Xml.Serialization.XmlElementAttribute("query")]
      public queryA[] Items {
          get {
              return this.itemsField;
          }
          set {
              this.itemsField = value;
          }
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Any Ideas?</p>