The webresponse i got from a server is shown like this. I am able to deserialze few values. But i dont kow how to convert the Availabilty to an Array.
<AvailRateChartRS Version="1">
<SoldMessage>sold</SoldMessage>
<RoomTypes>
<RoomType>
<RoomTypeId>1</RoomTypeId>
<SubPropertyId>1</SubPropertyId>
<Name>Villa</Name>
<MaxOccupancy>4</MaxOccupancy>
<BookingRangeAvailable>false</BookingRangeAvailable>
<Availability Id="1" Date="2012-10-16" Available="false" NoOfRoomsAvailable="0" />
<Availability Id="2" Date="2012-10-17" Available="false" NoOfRoomsAvailable="0" />
<Availability Id="3" Date="2012-10-18" Available="false" NoOfRoomsAvailable="0" />
<Availability Id="4" Date="2012-10-19" Available="false" NoOfRoomsAvailable="0" />
<Availability Id="5" Date="2012-10-20" Available="false" NoOfRoomsAvailable="0" />
<Availability Id="6" Date="2012-10-21" Available="false" NoOfRoomsAvailable="0" />
</RoomType>
</RoomTypes>
</AvailRateChartRS>
The Class for serializing is like this now.
namespace Classes
{
[Serializable()]
public class RoomType
{
[XmlElement("RoomTypeId")]
public string RoomTypeId { get; set; }
[XmlElement("SubPropertyId")]
public string SubPropertyId { get; set; }
[XmlElement("Name")]
public string Name { get; set; }
[XmlElement("MaxOccupancy")]
public string MaxOccupancy { get; set; }
[XmlElement("BookingRangeAvailable")]
public string BookingRangeAvailable { get; set; }
[XmlElement("Availability")]
public string Availability { get; set; }
}
[Serializable()]
[System.Xml.Serialization.XmlRoot("AvailRateChartRS")]
public class RoomTypes
{
[XmlArray("RoomTypes")]
[XmlArrayItem("RoomType", typeof(RoomType))]
public RoomType[] RoomType { get; set; }
}
}
Do i need to find any regular expression and put the availability in . Or is there any straight forward method. This is just a beginning am i expect issues like this much more. The web responses are not standardized thoroughly and often get some wild responses.