I’ve got this XML;
<ChartXml>
<Category type="xAxis">
<Value>Mon</Value>
<Value>Tue</Value>
<Value>Wed</Value>
<Value>Thurs</Value>
<Value>Friday</Value>
</Category>
</ChartXml>
And this class structure;
[XmlRoot("ChartXml")]
public class ChartXml
{
[XmlElement("Category")]
public Category Category;
}
public class Category
{
[XmlAttribute("type")]
public string Type;
[XmlArray("Value")]
public List<string> Values;
}
Now when I try to serialise the XML to a ChartXml object, I get object containing the Category with the type attribute set correctly, but i dont get my list of strings.
I’m guessing its something wrong with the way i’ve set up my classes.
Thanks,
james.
Use
[XmlElement("Value")]instead of[XmlArray("Value")], e.g.:Serialization:
Output: