I have an xml file coming down from TeamCity that looks like this (no other elements):
<builds count="2">
<build id="1" number="100" running="true" (etc) />
<build id="2" number="200" running="true" (etc) />
<build id="3" number="200" running="true" (etc) />
</builds>
My data contracts look like this:
[Serializable,DataContract(Name="builds", Namespace = "")]
public class builds
{
[XmlArray]
public build[] build;
[XmlAttribute("count")]
public int count { get; set; }
}
[Serializable, DataContract(Name = "build", Namespace = "")]
public class build
{
[XmlAttribute("id")]
public int id;
[XmlAttribute("number")]
public int number;
[XmlAttribute("running")]
public bool running;
[XmlAttribute("percentageComplete")]
public int percentageComplete;
[XmlAttribute("status")]
public string status;
[XmlAttribute("buildTypeId")]
public string buildTypeId;
[XmlAttribute("startDate")]
public string startDate;
[XmlAttribute("href")]
public string href;
[XmlAttribute("webUrl")]
public string webUrl;
}
Clearly I wouldn't be here if that was working :) How do I fix an issue with serialization of top level array elements that are all named the same? If I make it into a single instance of build it works fine and I can interact with the object.