Windows Phone 8 - Error while Serializing/Deserializing XML

Unimatrix

New Member
I have a Class A and Class B that contains List of class A objects.\[code\]public class Item{ public string X{ get; set; } public string Y{ get; set; }}public class ItemCollection{ List<Item> items = new List<Item>(); //Some methods}\[/code\]I can serialize it by:\[code\]IsolatedStorageFileStream ifs = new IsolatedStorageFileStream("myxml.xml", FileMode.Open, isfile);DataContractSerializer ser = new DataContractSerializer(itemlist.items.GetType());XmlWriter writer = XmlWriter.Create(ifs);ser.WriteObject(writer, itemlist.items);\[/code\]But while deserializing it, I get "... Root element is missing." error.\[code\]IsolatedStorageFileStream ifs = new IsolatedStorageFileStream("myxml.xml", FileMode.Open, isfile);DataContractSerializer ser = new DataContractSerializer(itemlist.Items.GetType());XmlReader reader=XmlReader.Create(ifs);itemlist.items= (List<Item>)ser.ReadObject(reader);\[/code\]Is there any other/better way of serializing/deserializing one class that contains list/collection of another class?
 
Back
Top