Monday, November 15, 2010

XML to class library


    The fast way to convert XML file to class library for (C#, managed C++ and etc.)

1. Launch Visual Studio Command Prompt
for example:
Start menu -> Visual Studio 2008 -> Visual Studio Tools -> Visual Studio Command Prompt

    2. Select folder with your XML file

    3. Type command XSD
xsd.exe your_file.xml

    4. And the folow command will convert current xsd file to class library
    xsd.exe -c -l:c# -n:XmlSerializationHowTo your_file.xsd

The parameter -l is language. You can choose from 'CS', 'VB', 'JS', 'VJS', 'CPP'
Also you can define special namespace for these classes to use parameter -n

Launch xsd.exe /? to get more information about this command.