XSD Code Generator

16,604

Solution 1

The XSD.exe utility (which is installed with Visual Studio) is capable of creating an XSD file from an XML file.

Here's the link on MSDN

I believe it may also part of the .NET SDK, meaning you would not need a full-blown Visual Studio installation.

Solution 2

Visual Studio does it pretty well too... Open XML file.. Choose 'Generate Schema' Command from XML menu

Solution 3

I am a little late to the part, but I find that Businessware Architects CodeXS is very good. I have found that it handles complex schema's much better.

Solution 4

I'm note sure it is useful. After all, it cannot infer everything: if an element is present in the XML document, how to know if it is mandatory or not?

Examplotron, to achieve a similar goal, relies, at least partly, on annotations.

Solution 5

And old question I know but this might help someone: http://www.freeformatter.com/xsd-generator.html. Simple online tool and gets the job done with ease. Perfect for quick XML schema generation.

Share:
16,604
George Stocker
Author by

George Stocker

Updated on June 02, 2022

Comments

  • George Stocker
    George Stocker almost 2 years

    Are there any Code Generators that would take a well-formed XML document, and write out an XSD schema based on how the XML document is structured?

  • George Stocker
    George Stocker over 15 years
    I'm trying to find the file on my harddrive. Where's the darned thing located?
  • Chris
    Chris over 15 years
    if you open a vs command prompt, just type xsd
  • Vyas Bharghava
    Vyas Bharghava over 15 years
    This command may be running the XSD tool behind the scenes... Unfortuantely, I had to move to a different machine and do not have VS.Net installed yet to verify this.
  • George Stocker
    George Stocker over 15 years
    Ah. I was looking for the physical .exe file. Silly me. I finally found it in %Program Files%\Microsoft SDKs\Windows\v6.0A\bin
  • leppie
    leppie over 15 years
    Weird, I didnt know xsd could do inference too :) Thanks!
  • joedotnot
    joedotnot about 14 years
    I doubt it's the same tool, the ouput XSD inferred from the same XML file was quite different - and the Visual Studio version looked more correct !
  • Brady Moritz
    Brady Moritz almost 14 years
    It definitely does run xsd.exe. You may get different results due to the various parameters you can provide to it.
  • S Meaden
    S Meaden about 9 years
    I dispute boomhauer's remark here. I have a massive 40 megabyte file which xsd is choking on and Visual Studio manages fine.