Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>During the serialization, replace "encoding="utf-16" with "encoding="utf-8"" and that will cut it. The source of the problem - I'm not sure, but I've ran into it numerous times, and that's how I dealt with it.</p> <p>That's how to deal with the IE issue.</p> <p>The deserialization should be amongst these lines. I'm posting the kind of arbitrary code I normally use:</p> <pre><code>public static object DeserializeFromXML&lt;T&gt;(string _input) { object _temp = Activator.CreateInstance&lt;T&gt;(); Type expected_type = _temp.GetType(); _temp = null; XmlSerializer serializer = new XmlSerializer(expected_type); StringReader stringWriter = new StringReader(_input); object _copy = serializer.Deserialize(stringWriter); return _copy; } </code></pre> <p>In the above example, I'm using templating for reusability sake. You should be able to call the method by saying <strong>DeserializeFromXML &lt; Class1 >(_xml_input)</strong> where xml input is the string. That will force the compiler to use the definition of the given class to deserialize the XML input. That way you wouldn't even have to change the encoding in the serialization. If it's also a case where you may or may not know the data type to deserialize with, you can use a strategy design pattern where you register the root type of the XML with it's associated generic type. Later on you can reference that registry and arbitrarily deserialize any XML input as long as the root type is registered. It's a trick i normally use as well. If more is needed on this, let me know, and I'll explain in detail.</p> <p>In addition,if you are running IE 9, the new update to IE 9 makes it difficult to view XML. Press F12 - go to developer tools and change your browser mode to run as IE 8 instead of IE 9.</p>
 

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