I have an application that is using XML to send and receive information. I will receive XML data like the following:
<?xml version="1.0" encoding="ASCII" ?>
<Response>
<ID>1234567</ID>
<Transaction>Connect</Transaction>
<Data>data</Data>
</Response>
Based on the value in the 'Transaction' I field, I plan to use XmlSerializer.Deserialize to deserialize the data packets to the appropriate class type. The example above would be the 'Connect' class that I would have to deserialize to:
using System.Xml.Serialization;
namespace XMLResponse
{
[XmlRoot("Response")]
public class Connect
{
public Connect()
{
}
public long ID { get; set; }
public string Transaction { get; set; }
public string Data { get; set; }
}
}
I am receiving the data as a byte array right now, I am putting it in a MemoryStream for use with XmlSerializer.Deserialize, but I can put it in a string if needed. What is the best way to pull out that field so I can Deserialize with the right class?