Use this code:
DetailList dl;
XmlSerializer xmls = new XmlSerializer(typeof(List<DetailList>))
using (Stream fs = new FileStream(@"C:\path\to\file.xml", FileMode.Open))
dl = (DetailList)xmls.Deserialize(fs);
Make sure you have populated your classes with the correct attributes. Use
using System.Xml.Serialization;
// ...
[Serializable]
public class Detail
{
[XmlElement]
public string Name1 { get; set; }
[XmlElement]
public string Name2 { get; set; }
// REQUIRED: a parameterless constructor for XmlSerializer (can be private)
private Detail(){}
public Detail(string name1, string name2)
{
Name1 = name1;
Name2 = name2;
}
}
[Serializable, XmlRoot("Details")]
public class DetailList : List<Detail>
{
}