Visual Studio ships with a tool called Xsd.exe that will automatically generate XSD based on an XML file. To use Xsd.exe, you will need to open up a Visual Studio command prompt. Click “Start,” point to “All Programs,” point to “Microsoft Visual Studio 2008,” point to “Visual Studio Tools” and then click “Visual Studio 2008 Command Prompt”. Now type xsd followed by the name of the XML file you want to parse:

xsd planets.xml

This will create a file called planets.xsd.

You can read more here:

http://msdn2.microsoft.com/en-us/library/x6c1kb0s(vs.71).aspx