// 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; using System.Xml.Serialization; namespace E { [XmlRoot("paymentService")] public class ReplyCancelled { [XmlAttribute("merchantCode")] public string MerchantCode { get; set; } [XmlElement] public ReplyCancel reply { get; set; } } public class ReplyCancel { [XmlElement("ok")] public ok ok { get; set; } } public class ok { [XmlElement] public cancelRecieved cancelRecieved { get; set; } } public class cancelRecieved { [XmlAttribute("orderCode")] public string orderCode { get; set; } } public class Program { public static void Main(string[] args) { string xmlstr = @" "; XmlSerializer ser = new XmlSerializer(typeof(ReplyCancelled)); ReplyCancelled rc = (ReplyCancelled)ser.Deserialize(new StringReader(xmlstr)); Console.WriteLine(rc!=null); Console.WriteLine(rc.reply!=null); Console.WriteLine(rc.reply.ok!=null); Console.WriteLine(rc.reply.ok.cancelRecieved!=null); Console.WriteLine(rc.reply.ok.cancelRecieved.orderCode); } } }