0

I am working with a huge XML using a tool in VS2010 able to convert it into a Model (.cs class). Now in order to read that XML, I am parsing through the tags and filling in my objects in the Model. Just want to know if I am on the right track or there's a easier way to now load the Model with xml data

Charu
  • 2,679
  • 6
  • 35
  • 52
  • 1
    possible duplicate of [How to Deserialize XML document](http://stackoverflow.com/questions/364253/how-to-deserialize-xml-document) – Gusdor Jan 28 '14 at 10:19

1 Answers1

2

You can use the XmlSerializer class to do this for you.

using(StreamReader reader = File.OpenText("FilePath"))
{
   XmlSerializer serial = new XmlSerializer(typeof(MyModel));
   MyModel model = serial.Deserialize(reader);
}
ywm
  • 1,107
  • 10
  • 14