I want to output the .xsd based on my xml file. When I generate the .xsd file, the only content I get inside it is: System.Xml.Schema.XmlSchema

When I generate the XSD using Visual Studio option to create Schema, it comes out properly. However, I have over 150 xml docs that I need to create XSD for hence need a programmatic option. Can anyone help?

If you specify an XML file (.xml extension), Xsd.exe infers a schema
from the data in the file and produces an XSD schema. The output file
has the same name as the XML file, but with the .xsd extension.

The following command generates an XML schema from myFile.xml and saves it to the specified directory.

Care to comment what is wrong with this answer?
– LaoujinApr 3 '14 at 11:35

I stumbled across this thread looking for related Q&A. About your downvote, I'm guessing someone might have tried to type 'nameOf.xsd' at the command line rather than 'xsd nameOf.xsd ...'. The other answers provided within minutes of yours seem to be more complete, so someone might have down-voted yours purely in comparison to others (not good form). And you're suggesting a batch file around xsd which shifts the code effort from C# to shell scripting. Meh, I wouldn't be fond of that either but I won't down-you for it. HTH
– TonyGAug 24 '14 at 23:17

2

He wanted to create 150 of these xsds. One would expect any code to be written for that to be throwaway code. You can either write 1 line of PS or 50 lines of C#...
– LaoujinAug 25 '14 at 9:36

Download microsoft visual studio 2010 or 2012.its very easy. Just click right on .xml file then choose microsft visual studio,then you will see xml tab, click then xml schema. It will generate xsd, save it to your local.