Reputation: 2749
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
Upvotes: 0
Views: 72
Reputation: 1127
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);
}
Upvotes: 2