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.
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.
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.
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)