tags:

views:

278

answers:

3
+1  Q: 

From XML to XSD

If i have a complex XML file, is there a cheap or free way to get a rough approximation of an XSD from it?

+1  A: 

If you use Visual Studio, it includes a console program called xsd.exe that can automatically generate schemas from xml.

It also can automatically generate classes or datasets from schemas.

Joel Coehoorn
A: 

Yes. There are tools that can analyse your XML and provide an XSD. For example, Visual Studio 2005 and 2008 include a Create XSD command from within the IDE as well as a command line tool, xsd.exe, that will do this.

However, note that it can only deduce the XSD from your provided XML, so the XSD may only validate that one file correctly. Once you've created your XSD, you should consider refactoring it against other XML files to ensure it properly fits the format you want to validate.

Jeff Yates
A: 

XmlSpy also has this feature. If it's better than VS i don't know. But for working with xml and xsds I prefer et over VS any day

Rasmus
XmlSpy is good, but if you've already paid for VS it can be hard to convince the powers that be to invest more money.
Jeff Yates
XmlSpy is available in a free home edition as well
Rasmus