Generate C# Class from XML

In Visual Studio it is possible to paste the XML file’s content as Classes. But what if you want to parse several XML files and have their corresponding C# Classes generated? To do that you can also use the xsd.exe tool.

So in short, use the following example batch file to generate the classes you need.

@ECHO OFF
REM Date: 22-feb-2022
REM Author: botten@mprise.nl
REM Description: Convert XML file to C# Class

SET XSD="c:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\xsd.exe"
SET SOURCE="d:\Temp\xml\My-Quiz.xml"

%XSD% %SOURCE%
pause