I have a document with this kind of structure:
<page name="some-name">
<header>
//some content
</header>
<section header="value">
//some content
</section>
</page>
When I deserialize this document to get an instance of Page class, I always get reflection error and InvalidOperationException. I figured out by debugging and a lot of try and error that the reason for this error is that i have the same name for a node (XMLElement) and a property (XMLAttribute), in this example the name is "header". XML structure is not changeable in any way, so that is not the solution. Is there a way to make it work, or do I have to add the property value later, outside of deserialization?
Classes are in this form:
[XmlType("page")]
public class Page
{
[XmlAttribute("name")]
public string Name { get; set }
[XmlElement("header")]
public Header Header { get; set }
[XmlElement("section")]
public Section Section { get; set }
}
[XmlType("section")]
public class Section
{
[XmlAttribute("header")]
public string Header { get; set }
}
[XmlType("header")]
public class Header
{
//elements and attributes as properties
}