Generate XSD For Existing Classes

If you’re sharing XML between applications, you need to communicate and agree upon the format of the XML. A common way to do this is by using XSD files. Microsoft’s XSD tool (XSD.exe) allows you to generate an XSD for an existing class quickly and easily. (I recommend using a Visual Studio Command Prompt. This is not necessary, but it saves you from having to browse to the XSD tool’s directory or worry about environment variables.)

The usage to do this is as follows:

xsd {file.dll | file.exe} [/outputdir:directory] [/type:typename [...]][/parameters:file.xml]

Typically, I’ll either generate an XSD for an entire DLL or a single class. If you choose to do a single class, it will also include classes that are dependencies.

xsd myassembly.dll
xsd myassembly.dll /type:myclass

Read more about the XSD tool at MSDN:

%d bloggers like this: