When handling with xml files, serialization is a good approach for reading and writing these files. But sometimes it needs some time to generate the classes we need.

When we have already an xml file and need to read this file via deserialization, we can use XSD (part of Visual Studio 20xx) to create an xsd file with the schema of the xml file. Simply run

XSD {name_of_xml_file}

And you will find the xsd file in the same directory.

When we have the xsd file, we can use XSD again to create the C# classes by running

XSD {name_of_xsd_file} /c /l:c#

This command will create the cs file we can use in our Visual Studio project.

The generated cs file will come up without any namespace definition, so it could be used in any Visual Studio project without any modification.