I have an Xml document that looks similar too
<Reports xmlns="">
<Report>
<ReportID>1</ReportID>
<ParameterTemplate />
</Report>
</Reports>
It fails serializing to this object
[XmlType(TypeName = "Report")]
public class Report
{
[XmlElement("ReportID")]
public int ID { get; set; }
[XmlElement("ParameterTemplate")]
public XElement ParameterTemplate { get; set; }
}
It's failing because the empty ParameterTemplate element, because if it contains child elements it deserializes fine.
How can I get this to work?
This is my Deserialization Code
var serializer = new XmlSerializer(typeof(Report));
return (Report)serializer.Deserialize(source.CreateReader());
The exception is
The XmlReader must be on a node of type Element instead of a node of type EndElement.
How can I get this to deserialize with the existing xml?
Thanks -c