views:

313

answers:

2

OK, I generated C# classes from my huge XSD file. Now I have a set of C# classes, XSD schema and actual XML data. Is there an automatic or semi-automatic way to fill these class instances with XML data that I have?

Thank you.

+1  A: 

You use the xml serialization/deserialization to export/import data to xml. Take a look at the XmlSerializer class. An example is on the msdn page.

Grzenio
+2  A: 

If you have used xsd.exe to generate the classes, then XmlSerializer should do the job...

XmlSerializer ser = new XmlSerializer(typeof(RootType));
RootType type = (RootType) ser.Deserialize(source)
Marc Gravell