Xml deki elementleri object olarak generic list e dönüştürmek istiyorum. örneğin;
<Updates> <Update> <MemberID>1</MemberID> <AnalysisID>1</AnalysisID> <MemberName>XXXXXXXXXXXXX</MemberName> </Update> <Update> <MemberID>1</MemberID> <AnalysisID>2</AnalysisID> <MemberName>YYYYYYYYYYYYY</MemberName> </Update> <Update> <MemberID>1</MemberID> <AnalysisID>3</AnalysisID> <MemberName>ZZZZZZZZZZZZ</MemberName> </Update> </Updates>
public class Update { [XmlElement(ElementName = "MemberID")] public int MemberID { get; set; } [XmlElement(ElementName = "AnalysisID")] public int AnalysisID { get; set; } [XmlElement(ElementName = "MemberName")] public string MemberName { get; set; } }
Toplam 1 cevap
public class Updates { [XmlElement("Update")] public List<Update> updateList= new List<Address>(); } public class Update { public int MemberID{ get; set; } public intAnalysisID{ get; set; } public string MemberName { get; set; } } XmlSerializer deserializer = new XmlSerializer(typeof(Updates)); TextReader reader = new StreamReader("Xml_dosya_yolu"); object obj = deserializer.Deserialize(reader); Updates XmlData = (Updates)obj; reader.Close();