Getting the following error. Seems like there could be many possible reasons for this from other threads. I've kept my code as simple as possible.
There is an error in XML document (2, 2).
public class MovieSummary
{
public List<Movie> Movies { get; set; }
}
public class Movie
{
public int id { get; set; }
public string name { get; set; }
}
public static MovieSummary Deserialize()
{
using (TextReader reader = new StreamReader("c:\\movies.xml"))
{
XmlSerializer serializer = new XmlSerializer(typeof(MovieSummary));
return (MovieSummary)serializer.Deserialize(reader);
}
}
public ActionResult GetListOfMovies()
{
MovieSummary summary = Deserialize();
return View(summary);
}
<?xml version="1.0" ?>
<movies xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<movie>
<id>1</id>
<name>The Dark Knight</name>
</movie>
</movies>