I serialize XML files to objects. Let's not talk about how I serialize it as it's not the problem. The problem is how to build a class for complex type elements. For normal XML elements, I do it follows (using System.Xml.Serialization of course)
public class Item
{
[XmlElement("thumbnail")]
public string thumbnail { get; set; }
}
All works good. But for a complex type, I don't know how to represent it in a class, I tried to represent it by an array like this
public class Item
{
[XmlArray("thumbnail")]
[XmlArrayItem("url")]
public string url { get; set; }
[XmlArrayItem("width")]
public string width { get; set; }
[XmlArrayItem("height")]
public string height { get; set; }
public string[] thumbnail { get; set; }
}
but this didn't work.
any ideas how to represent an XML complex element in a C# class?
xsd.exethat can take a schema fileschema.xsdand generate C# (or VB) classes from it so you could simply use that tool to generate your classes or at least to have a sample to start with: msdn.microsoft.com/en-us/library/x6c1kb0s%28v=vs.110%29.aspx