XML serialization array in C#

gottHonsseels

New Member
I'm having trouble figuring this out, I have an xml sheet that looks like this\[code\]<root> <list id="1" title="One"> <word>TEST1</word> <word>TEST2</word> <word>TEST3</word> <word>TEST4</word> <word>TEST5</word> <word>TEST6</word> </list> <list id="2" title="Two"> <word>TEST1</word> <word>TEST2</word> <word>TEST3</word> <word>TEST4</word> <word>TEST5</word> <word>TEST6</word> </list></root>\[/code\]And I'm trying to serialize it into\[code\]public class Items{ [XmlAttribute("id")] public string ID { get; set; } [XmlAttribute("title")] public string Title { get; set; } //I don't know what to do for this [Xml... something] public list<string> Words { get; set; } }//I don't this this is right either[XmlRoot("root")]public class Lists{ [XmlArray("list")] [XmlArrayItem("word")] public List<Items> Get { get; set; }}//Deserialize XML to Lists Classusing (Stream s = File.OpenRead("myfile.xml")){ Lists myLists = (Lists) new XmlSerializer(typeof (Lists)).Deserialize(s);}\[/code\]I'm really new with XML and XML serializing, any help would be much appreciated
 
Back
Top