I have the following code which is supposed to deserialize an XML string into a Class that has most of the items in the XML file, it may not have all them which is fine they should just assume NULL.
When i run the following code using the XML below it leaves each value as NULL.
Any pointers for where i'm going wrong
Thanks
ServiceResponse ReturnVal = new ServiceResponse();
try
{
XmlSerializer serializer = new XmlSerializer(typeof(ServiceResponse));
StringReader sr = new StringReader(XMLResponse);
NamespaceIgnorantXmlTextReader XMLWithoutNamespace = new NamespaceIgnorantXmlTextReader(sr);
ReturnVal = (ServiceResponse)serializer.Deserialize(XMLWithoutNamespace);
}
catch (Exception ex)
{
throw ex;
}
[XmlRoot("ServiceResponse")]
public class ServiceResponse
{
public string RequestType { get; set; }
public string ApplicationSender { get; set; }
public string WorkstationID { get; set; }
public string POPID { get; set; }
public string RequestID { get; set; }
public string ReferenceNumber { get; set; }
public string ProtocolVersion { get; set; }
public string DeviceType { get; set; }
public string SWChecksum { get; set; }
public string CommunicationProtocOl { get; set; }
public string Model { get; set; }
public string ApplicationSoftwareVersion { get; set; }
public string Manufacturer_Id { get; set; }
public string OverallResult { get; set; }
}
public class NamespaceIgnorantXmlTextReader : XmlTextReader
{
public NamespaceIgnorantXmlTextReader(System.IO.TextReader reader) : base(reader) { }
public override string NamespaceURI
{
get { return ""; }
}
}
XMLResponse will be equal too the following:
<?xml version="1.0" encoding="UTF-8" standalone="no"?><ServiceResponse RequestType="Login" ApplicationSender="QWERTY" WorkstationID="1" RequestID="1254" ProtocolVersion="12" DeviceType="1" SWChecksum="1" CommunicationProtocol="11" Model="1" ApplicatioSoftwareVersion="010" Manufacturer_Id="0" OverallResult="Success" xmlns="http://www.nrf-arts.org/IXRetail/namespace" xmlns:IFSF="http://www.ifsf.org/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.nrf-arts.org/IXRetail/namespace C:\Schema\ServiceResponse.xsd" />