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
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);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.