I have an XML document similar to the following:
...
I am hoping to use the System.Xml.Serialization
attributes to simplify XML deserialization. The issue I have is I cannot work out how to specify that the root node contains an array.
I have tried creating the following classes:
[XmlRoot("scan_details")] public class ScanDetails { [XmlArray("object")] public ScanDetail[] Items { get; set; } } public class ScanDetail { [XmlAttribute("name")] public string Filename { get; set; } }
However when I deserialize the XML into the ScanDetails
object the Items
array remains null
.
How do I deserialize an array in a root node?