I need to serialize an Object to XML and back. The XML is fix and I can\'t change it.
I fail to generate this structure after bookingList.
How can I \"
Try decorating the properties of the bookingListclass with the XmlElementAttribute, in order to control how the objects of that class are going to be serialized to XML.
Here's an example:
public class bookingList
{
[XmlElement(Order = 1)]
public string error { get; set; }
[XmlElement(Order = 2)]
public int counter { get; set; }
[XmlElement(ElementName = "booking", Order = 3)]
public List bookings = new List();
}
public class booking
{
public int id { get; set; }
}
In my test I obtained this output:
sample
0
1
2
3
Related resources: