Note that there are some explanatory texts on larger screens.

plurals
  1. PO{"<user xmlns=''> was not expected.} Deserializing Twitter XML
    primarykey
    data
    text
    <p>So im pulling in the XML from Twitter via OAuth</p> <p>So Im doing a request to <a href="http://twitter.com/account/verify_credentials.xml" rel="noreferrer">http://twitter.com/account/verify_credentials.xml</a></p> <p>Which returns the following XML </p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&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 Deserialise</p> <pre><code> public User VerifyCredentials() { string url = "http://twitter.com/account/verify_credentials.xml"; string xml = _oauth.oAuthWebRequestAsString(oAuthTwitter.Method.GET, url, null); XmlSerializer xs = new XmlSerializer(typeof(User),""); MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(xml)); return (User)xs.Deserialize(ms); } </code></pre> <p>And i have the following for my User Class </p> <pre><code> [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)] public partial class User { [XmlElement(ElementName = "id")] public long Id { get; set; } [XmlElement(ElementName = "name")] public string Name { get; set; } [XmlElement(ElementName = "screen_name")] public string ScreenName { get; set; } [XmlElement(ElementName = "location")] public string Location { get; set; } [XmlElement(ElementName = "description")] public string Description { get; set; } [XmlElement(ElementName = "profile_image_url")] public string ProfileImageUrl { get; set; } [XmlElement(ElementName = "url")] public string Url { get; set; } [XmlElement(ElementName = "protected")] public bool Protected { get; set; } [XmlElement(ElementName = "followers_count")] public int FollowerCount { get; set; } [XmlElement(ElementName = "profile_background_color")] public string ProfileBackgroundColor { get; set; } [XmlElement(ElementName = "profile_text_color")] public string ProfileTextColor { get; set; } [XmlElement(ElementName = "profile_link_color")] public string ProfileLinkColor { get; set; } [XmlElement(ElementName = "profile_sidebar_fill_color")] public string ProfileSidebarFillColor { get; set; } [XmlElement(ElementName = "profile_sidebar_border_color")] public string ProfileSidebarBorderColor { get; set; } [XmlElement(ElementName = "friends_count")] public int FriendsCount { get; set; } [XmlElement(ElementName = "created_at")] public string CreatedAt { get; set; } [XmlElement(ElementName = "favourties_count")] public int FavouritesCount { get; set; } [XmlElement(ElementName = "utc_offset")] public int UtcOffset { get; set; } [XmlElement(ElementName = "time_zone")] public string Timezone { get; set; } [XmlElement(ElementName = "profile_background_image_url")] public string ProfileBackgroundImageUrl { get; set; } [XmlElement(ElementName = "profile_background_tile")] public bool ProfileBackgroundTile { get; set; } [XmlElement(ElementName = "statuese_count")] public int StatusesCount { get; set; } [XmlElement(ElementName = "notifications")] public string Notifications { get; set; } [XmlElement(ElementName = "geo_enabled")] public bool GeoEnabled { get; set; } [XmlElement(ElementName = "Verified")] public bool Verified { get; set; } [XmlElement(ElementName = "following")] public string Following { get; set; } [XmlElement(ElementName = "status", IsNullable=true)] public Status CurrentStatus { get; set; } } </code></pre> <p>But when its deserialising the above Xml i get the following Error thrown</p> <ul> <li><p>$exception {"There is an error in XML document (2, 2)."} System.Exception {System.InvalidOperationException}</p></li> <li><p>InnerException {"&lt;user xmlns=''&gt; was not expected."} System.Exception {System.InvalidOperationException}</p></li> </ul> <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 im not serializing it so i cant.</p> <p>I also have some code for recieving Statuses, which works fine.</p> <p>So can someone explain to me what and why the error is happening? As well as a possible solution?</p> <p>Thanks in advance</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload