<?xml version="1.0" encoding="utf-8" ?> <InfoList> <Info> <Code>A1</Code> <Description>Something</Description> </Info> <Info> <Code>A2</Code> <Description>SomethingElse</Description> </Info> <Info> <Code>A3</Code> <Description>A Widget</Description> </Info> </InfoList>then:
using System.Xml.Linq; using System.Xml.Serialization; public class Program { public static void Main() { var myXML = XDocument.Load("theXMLFile.xml"); System.Xml.XmlReader reader = myXML.CreateReader(); var s = new XmlSerializer(typeof(InfoList)); var result = (InfoList)s.Deserialize(reader); } } [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)] [System.Xml.Serialization.XmlRootAttribute(Namespace = "", IsNullable = false)] public partial class InfoList { [System.Xml.Serialization.XmlElementAttribute("Info")] public Info[] Info { get; set; } } [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)] public partial class Info { public string Code { get; set; } public string Description { get; set; } }You can load the XDocument from a stream rather than a file as in my example. Also there's a little used function in VS that will create a fleshed out version of the classes for you: If you can copy an Xml example to the clipboard just set the cursor to the point where you want the class/classes to be created and use Edit/Paste Special/Paste XML as Classes.