I am actually stuck in my current project.
I’ve got a XML of the following structure:
<ExampleCol>
<ElementWithAttribute attr="null">ElementWithAttribute</ElementWithAttribute>
<AnotherCol>
<Row attr="row1">Name = 1 </Row>
<Row attr="row2"> Name = 2 </Row>
</AnotherCol>
<ExampleCol>
I am not able to change that XML structure.
Currently I am working with those classes:
[XmlRoot]
public class ExampleCol
{
[XmlElement("ElementWithAttribute")]
public ElementWithAttribute ewa1 {get;set}
[XmlElement("AnotherCol")]
public AnotherCol ac1 {get;set}
}
public class ElementWithAttribute
{
[XmlElement("ElementWithAttribute")
public string Value {get;set;}
[XmlAttribute("attr")
public string attr {get;set;}
}
public class AnotherCol
{
[XmlArray]
[XmlArrayItem("Row")
public Row[] RowCollection {get;set;}
}
public Row
{
[XmlElement("Row")]
public string Name {get;set;}
[XmlAttribute("attr")]
public string Attribute [get;set;]
}
Obviously it cannot deserialize AnotherCol and ElementWithAttribute.
(Obviously, because each class of Row and ElementWithAttribute expects a new element as a child.
But I’m just too dumb to see what changes I need to do to achieve my goals.
Anyone could provide me some hints?
Thanks in advance.
Here is the code you’ll require to be able to deserialize that set of XML: