Hi All,


 

I love these sorts of C# tools, just magic.


 

1.       Create an XML file.

2.       Create the xsd and class required

a.       Run xsd.exe file.xml -> this will generate an xsd file

                                                               i.      Mine was located at C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.7.2 Toolsxsd.exe

                                                             ii.      You may need to install an SDK

1.       Go to

2.       Install this

b.       Run xsd.exe file.xsd /classes -> this will generate a class

c.       Import the class into your project

3.       Add

using System.Xml;

using System.Xml.Serialization;

4.       Then all you need is this code to then de-serialise the xml file to the generated class(es).

XmlSerializer ser = new XmlSerializer(typeof(Templates));

        Templates template;

        using (XmlReader reader = XmlReader.Create(filename))

       {

            template = (Templates)ser.Deserialize(reader);

        }

5.       Result


 

Special Thanks: David Lucre (not that he will see this)


 

Regards,


 

Scott Deruniec