I receive xml file like this. I need to convert this xml to an object.
<?xml version="1.0" encoding="utf-8" ?>
<PrepaidBill>
<AccountDetails FCName="" TariffName="" Area="1000" SLDG="5000" SLEB="5000" ToDate="12/31/2013" FromDate="12/1/2013" Address="1st Cross, 26th Main, 9th block, Jayanagar" MeterNumber="DCPLCMTRXXX80001" ConsumerName="Pravin Nidoni"/>
</PrepaidBill>
How to deserialize it? I have created a class for XML like
namespace ConvertXMLtoObject
{
[XmlRoot("PrepaidBill")]
public class BOPrepaidBill
{
public AccountDetails AccountDetails { get; set; }
}
public class AccountDetails
{
[XmlAttribute("FCName")]
public string FCName { get; set; }
[XmlAttribute("TariffName")]
public string TariffName { get; set; }
[XmlAttribute("Area")]
public int Area { get; set; }
[XmlAttribute("SLDG")]
public int SLDG { get; set; }
[XmlAttribute("SLEB")]
public int SLEB { get; set; }
[XmlAttribute("ToDate")]
public DateTime ToDate { get; set; }
[XmlAttribute("FromDate")]
public DateTime FromDate { get; set; }
[XmlAttribute("Address")]
public string Address { get; set; }
[XmlAttribute("MeterNumber")]
public string MeterNumber { get; set; }
[XmlAttribute("ConsumerName")]
public string ConsumerName { get; set; }
}
}