I have XML document:
<?xml version="1.0" encoding="utf-8" ?>
<Menu>
<MainMenu>
<Meal>Example1</Meal>
<Meal>Example1</Meal>
<Meal>Example1</Meal>
<Meal>Example1</Meal>
<Meal>Example1</Meal>
<Meal>Example1</Meal>
</MainMenu>
</Menu>
And I whant to deserialize it as list in class MainMenu
:
[Serializable()]
public class MainMenu
{
[System.Xml.Serialization.XmlElementAttribute("Meal")]
private List<string> Meal;
public MainMenu()
{
Meal = new List<string>();
}
}
By method:
private void MenuDeserializer()
{
MainMenu mainMenu = null;
string path = "MenuXML.xml";
XmlSerializer serializer = new XmlSerializer(typeof(MainMenu));
StreamReader reader = new StreamReader(path);
reader.ReadToEnd();
mainMenu = (MainMenu)serializer.Deserialize(reader);
reader.Close();
}
Is this will deserialize all Meal's to my list? and if not than how to do this? When I'm trying to debug I get exception: Error at XML file (0,0), this (0,0) is confusing, where is problem and how to solve it?