// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.IO; using System.Xml.Serialization; namespace E { [XmlRoot("paymentService")] public class PaymentService { [XmlAttribute] public string merchantCode { get; set; } [XmlElement] public Reply reply { get; set; } } public class Reply { public OrderStatus orderStatus { get; set; } } public class OrderStatus { [XmlAttribute] public string orderCode { get; set; } [XmlElement] public Reference reference { get; set; } } public class Reference { [XmlAttribute] public int id { get; set; } [XmlText] public string Text { get; set; } } public class Program { public static void Main(string[] args) { string xmlstr = @" https://payments-est.worldpay.com/a47299817475202gGF_yXIZpho134rLgPcK2w "; XmlSerializer ser = new XmlSerializer(typeof(PaymentService)); PaymentService o = (PaymentService)ser.Deserialize(new StringReader(xmlstr)); Console.WriteLine(o.merchantCode); Console.WriteLine(o.reply.orderStatus.orderCode); Console.WriteLine(o.reply.orderStatus.reference.id); Console.WriteLine(o.reply.orderStatus.reference.Text); } } }