I have a problem deserializing an XML document. It gives me:
There is an error in XML document (1, 23). ---> System.InvalidOperationException: was not expected.
Here is my XML:
<?xml version="1.0" ?>
<car>
<msg>asdfgg</msg>
<userGUID>234234</userGUID>
<event>vfrewvwev</event>
</car>
This is my generated class:
[System.CodeDom.Compiler.GeneratedCodeAttribute("Xsd2Code", "3.4.0.37595")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
[System.Xml.Serialization.XmlRootAttribute(Namespace="", IsNullable=false)]
public partial class car: System.ComponentModel.INotifyPropertyChanged {...
and this is the deserialization method im using:
MyApp ma = MyApp.Deserialize(strXml);
public static MyApp Deserialize(string xml)
{
System.IO.StringReader stringReader = null;
try
{
stringReader = new System.IO.StringReader(xml);
return ((MyApp)(Serializer.Deserialize(System.Xml.XmlReader.Create(stringReader))));
}
finally
{
if ((stringReader != null))
{
stringReader.Dispose();
}
}
}