I have a problem in reserializing an XML file into C#. XML Looks like below
<?xml version='1.0' encoding='UTF-8'?>
<Report_Data>
<Report_Entry>
<CustomerId>CST100</CustomerId>
<TotalAmount>-210.34</TotalAmount>
</Report_Entry>
<Report_Entry>
<CustomerId>CST101</CustomerId>
<TotalAmount>-50.31</TotalAmount>
</Report_Entry>
</Report_Data>
POCO Class
[XmlRoot(ElementName = "Report_Data")]
public class CustomerInvoiceList
{
[XmlElement("Report_Entry")]
public List<ReportEntry> ReportEntry { get; set; }
}
[Serializable]
public class ReportEntry
{
[XmlElement(ElementName = "CustomerId")]
public string CustomerId{ get; set; }
[XmlElement(ElementName = "TotalAmount")]
public string TotalAmount{ get; set; }
}
//function to parse the input xml
public CustomerInvoiceList Parse(string inputData)
{
try
{
CustomerInvoiceList parsedResult;
var serializer = new XmlSerializer(typeof(CustomerInvoiceList));
using (TextReader reader = new StringReader(inputData))
{
parsedResult = (CustomerInvoiceList)serializer.Deserialize(reader);
}
return parsedResult;
}
catch (Exception ex)
{
throw ex;
}
When i have this input, the TotalAmount filed contains data like (50.31), after the deserialization. How do i get the decimal value including -, after the deserialization process.
Thanks
Tutu