I am trying to deserialize an Atom XML file created by one of the internal systems. However, when I try:
public static MyType FromXml(string xml) { XmlSerializer serializer = new XmlSerializer(typeof(MyType )); return (MyType) serializer.Deserialize(new StringReader(xml)); }
it throws an exception in the namespace definition:
System.InvalidOperationException: <feed xmlns='http://www.w3.org/2005/Atom'> was not expected.
When I add a namespace to the XmlSerializer constructor, my object is completely empty:
public static MyType FromXml(string xml) { XmlSerializer serializer = new XmlSerializer(typeof(MyType ), "http://www.w3.org/2005/Atom"); return (MyType) serializer.Deserialize(new StringReader(xml));
Any ideas how I can make it work?
Grzenio
source share