I am calling a REST webservice.
The response looks something like this:
<?xml version=\"1.0\" encoding=\"utf-8\"?>
<data>
<status>1</status>
<message>OK</message>
<results>
<result>
<account>12345</account>
<to>012345678</to>
<from>054321</from>
<message>Testing</message>
<flash></flash>
<replace></replace>
<report></report>
<concat></concat>
<id>f8d3eea1cbf6771a4bb02af3fb15253e</id>
</result>
</results>
</data>
I have a class called "SMSSendingResponse" which looks like this:
public class SMSSendingResponse
{
public string AccountNumber { get; set; }
public string Status { get; set; }
public string Message { get; set; }
public string ResponseID { get; set; }
public SMSMessage SMSMessage { get; set; }
}
SMSMessage looks like this:
public class SMSMessage
{
public string To { get; set; }
public string From { get; set; }
public string Message { get; set; }
}
As you can see, I'm ignoring some of the returned elemenst (flash, replace etc..)
What's the best way of me serializing the returned XML into this object?
I tried using XmlSerializer, but this threw an error... I guess because I'm not serializing first using XmlSerializer.
If it were Json, I'd use the NewtonSoft.Json library... Whilst i suppose i could convert xml to json, then serialize that way, is there a better way?