title: {"<user xmlns=''> was not expected.} Deserializing Twitter XML
body: <p>I'm pulling in the XML from Twitter via OAuth.</p>
  <p>I'm doing a request to <a href="http://twitter.com/account/verify_credentials.xml" rel="noreferrer">http://twitter.com/account/verify_credentials.xml</a>, which returns the following XML:</p>
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;user&gt;
    &lt;id&gt;16434938&lt;/id&gt;
    &lt;name&gt;Lloyd Sparkes&lt;/name&gt;
    &lt;screen_name&gt;lloydsparkes&lt;/screen_name&gt;
    &lt;location&gt;Hockley, Essex, UK&lt;/location&gt;
    &lt;description&gt;Student&lt;/description&gt;
    &lt;profile_image_url&gt;http://a3.twimg.com/profile_images/351849613/twitterProfilePhoto_normal.jpg&lt;/profile_image_url&gt;
    &lt;url&gt;http://www.lloydsparkes.co.uk&lt;/url&gt;
    &lt;protected&gt;false&lt;/protected&gt;
    &lt;followers_count&gt;115&lt;/followers_count&gt;
    &lt;profile_background_color&gt;9fdaf4&lt;/profile_background_color&gt;
    &lt;profile_text_color&gt;000000&lt;/profile_text_color&gt;
    &lt;profile_link_color&gt;220f7b&lt;/profile_link_color&gt;
    &lt;profile_sidebar_fill_color&gt;FFF7CC&lt;/profile_sidebar_fill_color&gt;
    &lt;profile_sidebar_border_color&gt;F2E195&lt;/profile_sidebar_border_color&gt;
    &lt;friends_count&gt;87&lt;/friends_count&gt;
    &lt;created_at&gt;Wed Sep 24 14:26:09 +0000 2008&lt;/created_at&gt;
    &lt;favourites_count&gt;0&lt;/favourites_count&gt;
    &lt;utc_offset&gt;0&lt;/utc_offset&gt;
    &lt;time_zone&gt;London&lt;/time_zone&gt;
    &lt;profile_background_image_url&gt;http://s.twimg.com/a/1255366924/images/themes/theme12/bg.gif&lt;/profile_background_image_url&gt;
    &lt;profile_background_tile&gt;false&lt;/profile_background_tile&gt;
    &lt;statuses_count&gt;1965&lt;/statuses_count&gt;
    &lt;notifications&gt;false&lt;/notifications&gt;
    &lt;geo_enabled&gt;false&lt;/geo_enabled&gt;
    &lt;verified&gt;false&lt;/verified&gt;
    &lt;following&gt;false&lt;/following&gt;
    &lt;status&gt;
      &lt;created_at&gt;Mon Oct 12 19:23:47 +0000 2009&lt;/created_at&gt;
      &lt;id&gt;4815268670&lt;/id&gt;
      &lt;text&gt;&amp;#187; @alexmuller your kidding? it should all be &amp;quot;black tie&amp;quot; dress code&lt;/text&gt;
      &lt;source&gt;&amp;lt;a href=&amp;quot;http://code.google.com/p/wittytwitter/&amp;quot; rel=&amp;quot;nofollow&amp;quot;&amp;gt;Witty&amp;lt;/a&amp;gt;&lt;/source&gt;
      &lt;truncated&gt;false&lt;/truncated&gt;
      &lt;in_reply_to_status_id&gt;4815131457&lt;/in_reply_to_status_id&gt;
      &lt;in_reply_to_user_id&gt;8645442&lt;/in_reply_to_user_id&gt;
      &lt;favorited&gt;false&lt;/favorited&gt;
      &lt;in_reply_to_screen_name&gt;alexmuller&lt;/in_reply_to_screen_name&gt;
      &lt;geo/&gt;
    &lt;/status&gt;
  &lt;/user&gt;
  </code></pre>
  <p>I am using the following code to deserialize:</p>
  
  <pre class="lang-cs prettyprint-override"><code>    public User VerifyCredentials()
      {
          string url = &quot;http://twitter.com/account/verify_credentials.xml&quot;;
          string xml = _oauth.oAuthWebRequestAsString(oAuthTwitter.Method.GET, url, null);
  
          XmlSerializer xs = new XmlSerializer(typeof(User),&quot;&quot;);
  
          MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(xml));
  
          return (User)xs.Deserialize(ms);
      }
  </code></pre>
  <p>And I have the following for my <code>User</code> class:</p>
  <pre class="lang-cs prettyprint-override"><code> [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]
  public partial class User
  {
  
      [XmlElement(ElementName = &quot;id&quot;)]       
      public long Id { get; set; }
  
      [XmlElement(ElementName = &quot;name&quot;)] 
      public string Name { get; set; }
  
      [XmlElement(ElementName = &quot;screen_name&quot;)]       
      public string ScreenName { get; set; }
  
      [XmlElement(ElementName = &quot;location&quot;)]       
      public string Location { get; set; }
  
      [XmlElement(ElementName = &quot;description&quot;)]      
      public string Description { get; set; }
  
      [XmlElement(ElementName = &quot;profile_image_url&quot;)]      
      public string ProfileImageUrl { get; set; }
  
      [XmlElement(ElementName = &quot;url&quot;)]       
      public string Url { get; set; }
  
      [XmlElement(ElementName = &quot;protected&quot;)]      
      public bool Protected { get; set; }
  
      [XmlElement(ElementName = &quot;followers_count&quot;)]      
      public int FollowerCount { get; set; }
  
      [XmlElement(ElementName = &quot;profile_background_color&quot;)]       
      public string ProfileBackgroundColor { get; set; }
  
      [XmlElement(ElementName = &quot;profile_text_color&quot;)]       
      public string ProfileTextColor { get; set; }
  
      [XmlElement(ElementName = &quot;profile_link_color&quot;)]       
      public string ProfileLinkColor { get; set; }
  
      [XmlElement(ElementName = &quot;profile_sidebar_fill_color&quot;)]       
      public string ProfileSidebarFillColor { get; set; }
  
      [XmlElement(ElementName = &quot;profile_sidebar_border_color&quot;)]      
      public string ProfileSidebarBorderColor { get; set; }
  
      [XmlElement(ElementName = &quot;friends_count&quot;)]     
      public int FriendsCount { get; set; }
  
      [XmlElement(ElementName = &quot;created_at&quot;)]     
      public string CreatedAt { get; set; }
  
      [XmlElement(ElementName = &quot;favourties_count&quot;)]      
      public int FavouritesCount { get; set; }
  
      [XmlElement(ElementName = &quot;utc_offset&quot;)]      
      public int UtcOffset { get; set; }
  
      [XmlElement(ElementName = &quot;time_zone&quot;)]       
      public string Timezone { get; set; }
  
      [XmlElement(ElementName = &quot;profile_background_image_url&quot;)]        
      public string ProfileBackgroundImageUrl { get; set; }
  
      [XmlElement(ElementName = &quot;profile_background_tile&quot;)]        
      public bool ProfileBackgroundTile { get; set; }
  
      [XmlElement(ElementName = &quot;statuese_count&quot;)]        
      public int StatusesCount { get; set; }
  
      [XmlElement(ElementName = &quot;notifications&quot;)]       
      public string Notifications { get; set; }
  
      [XmlElement(ElementName = &quot;geo_enabled&quot;)]       
      public bool GeoEnabled { get; set; }
  
      [XmlElement(ElementName = &quot;Verified&quot;)]        
      public bool Verified { get; set; }
  
      [XmlElement(ElementName = &quot;following&quot;)]
      public string Following { get; set; }
  
      [XmlElement(ElementName = &quot;status&quot;, IsNullable=true)]
      public Status CurrentStatus { get; set; }
  
  }
  </code></pre>
  <p>But when it's deserializing the above XML the application throws the following:</p>
  <blockquote>
  <p>$exception {&quot;There is an error in XML document (2, 2).&quot;} System.Exception {System.InvalidOperationException}</p>
  </blockquote>
  <blockquote>
  <p>InnerException {&quot;&lt;user xmlns=''&gt; was not expected.&quot;}    System.Exception {System.InvalidOperationException}</p>
  </blockquote>
  <p>Now I have searched around and the best solution I can find is to add blank namespaces to the serializer when you serialize the content, but i'm not serializing it so I can't.</p>
  <p>I also have some code for receiving Statuses, which works fine.</p>
  <p>So can someone explain to me why the error is happening? As well as a possible solution?</p>