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:


Author: Adam Prescott

I'm enthusiastic and passionate about creating intuitive, great-looking software. I strive to find the simplest solutions to complex problems, and I embrace agile principles and test-driven development.

Leave a comment

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: