Currently I'm working on some code that deserializes a XML file into an object. I have figured out most of the Attributes that I have to use to make this work except for one case, described below.
This is the XML document that I'm trying to Deserialize.
The pages-element is an array. The page-element is an object. The object-elements in the page are supposed to be in an array but they aren't when you take a look at the XML format. The amount of objects is variable though.
<document>
<pages>
<page>
<object></object>
<object></object>
<object></object>
</page>
<page>
<object></object>
</page>
<page>
<object></object>
<object></object>
</page>
</pages>
</document>
These are the classes that form the object that I'm trying to deserialize it to.
[XmlRoot("document")]
public class Document
{
[XmlArrayItem("page", typeof(Page))]
[XmlArray("pages")]
public Page[] pages;
}
[XmlRoot("page")]
public class Page
{
public Object[] objects;
}
[XmlRoot("object")]
public class Object
{
}
The question then is; what attributes do I need to enable the XmlSerializer class to deserialize the XML to a Document object?