I am having xml string as follows
"<?xml version=\"1.0\" encoding=\"utf-8\"?><p:Msg xmlns:tns=\"http://xyx.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.xyx.com/location/921.xsd\"><Header><Type>P:B2</Type><UserID>MARKISCOOL</UserID><MsgID>4213</MsgID>
</Header><Data><StatusRecord><TimestampUTCCurrent hex=\"40B18261\" intermediate=\"1085375073\" uom=\"\">2016-01-20T06:05:55Z</TimestampUTCCurrent>
<FileType hex=\"00002765\" intermediate=\"10003\" uom=\"\">10003</FileType>
</StatusRecord></Data></p:Msg>"
I have to deserialize this xml string into a object as shown
[XmlRoot(Namespace = "http://xyx.com", ElementName = "Msg", IsNullable = true)]
public class Info
{
public string Type { get; set; }
public string UserID { get; set; }
[XMlElement("MsgID")]
public int MessageId { get; set; }
public string TimestampUTCCurrent { get; set; }
public int FileType { get; set; }
}
I am trying to deserialize xml string into Info class,but I am getting null values into the Info class.I am not sure why values from xml are not copying into 'Info'object.
public Info Deserialize(string xmlString)
{
XDocument doc = XDocument.Parse(xmlString);
XmlSerializer xmlSerializer = new XmlSerializer(typeof(Info));
using (var reader = doc.Root.CreateReader())
{
return (Info)xmlSerializer.Deserialize(reader);
}
}