title: Deserialising XML without a declaration or namespace in Silverlight
body: <p>I've been landed with a feed of XML data that I need to deserialise into objects in a Silverlight (v5) application. The data looks like:</p>
  
  <pre><code>&lt;AgentState&gt;
    &lt;agentName&gt;jbloggs&lt;/agentName&gt;
    &lt;extension&gt;12345&lt;/extension&gt;
    &lt;currentlyIn&gt;TestStatus&lt;/currentlyIn&gt;
  &lt;/AgentState&gt;
  </code></pre>
  
  <p>I've created a class at the Silverlight side, and I'm trying to get this XML - which, you'll notice, is missing a declaration and a namespace - into objects.</p>
  
  <pre><code>StringReader sr = null;
  string data = Encoding.UTF8.GetString(e.Buffer, e.Offset, e.BytesTransferred);
  sr = new StringReader(data);
  XmlSerializer xs = new XmlSerializer(typeof (AgentState));
  AgentState agent = (AgentState) xs.Deserialize(sr);
  </code></pre>
  
  <p>.. but this throws an error <code>an error in xml document (1,2)</code>, as it's missing the declaration. Even manually adding a dummy declaration gives further errors about missing namespaces.</p>
  
  <p>I've found <a href="https://stackoverflow.com/questions/870293/can-i-make-xmlserializer-ignore-the-namespace-on-deserialization">other</a> questions about ignoring namespace/declarations in XML, but none of these seem to work in Silverlight.</p>
  
  <p>Can anyone advise on the best way to get this XML deserialised into an object?</p>