<p>I am looking for a tool which will take an XML instance document and output a corresponding XSD schema.</p>

<p>I certainly recognize that the generated XSD schema will be limited when compared to creating a schema by hand (it probably won't handle optional or repeating elements, or data constraints), but it could at least serve as a quick starting point.</p>

[{'answer_id': 74939, 'author': 'Danimal', 'author_id': 2757, 'author_profile': 'https://Stackoverflow.com/users/2757', 'pm_score': 7, 'selected': True, 'text': '<p>the <a href="https://msdn.microsoft.com/en-us/library/x6c1kb0s(v=vs.110).aspx" rel="noreferrer">Microsoft XSD inference tool</a> is a good, free solution. Many XML editing tools, such as XmlSpy (mentioned by @Garth Gilmour) or OxygenXML Editor also have that feature. They\'re rather expensive, though. BizTalk Server also has an XSD inferring tool as well.<br/></p>\n\n<p>edit: I just discovered the .net <a href="http://msdn.microsoft.com/en-us/library/system.xml.schema.xmlschemainference.aspx" rel="noreferrer">XmlSchemaInference</a> class, so if you\'re using .net you should consider that</p>\n'}, {'answer_id': 74943, 'author': 'Garth Gilmour', 'author_id': 2635682, 'author_profile': 'https://Stackoverflow.com/users/2635682', 'pm_score': 2, 'selected': False, 'text': '<p>Altova XmlSpy does this well - you can find an overview <a href="http://www.altova.com/products/xmlspy/dtd_editor.html" rel="nofollow noreferrer">here</a></p>\n'}, {'answer_id': 80570, 'author': 'Robert Gould', 'author_id': 15124, 'author_profile': 'https://Stackoverflow.com/users/15124', 'pm_score': 3, 'selected': False, 'text': '<p>If all you want is XSD, LiquidXML has a free version that does XSDs, and its got a GUI to it so you can tweak the XSD if you like. Anyways nowadays I write my own XSDs by hand, but its all thanks to this app.</p>\n\n<p><a href="http://www.liquid-technologies.com/" rel="noreferrer">http://www.liquid-technologies.com/</a></p>\n'}, {'answer_id': 88683, 'author': 'Pat Hermens', 'author_id': 1677, 'author_profile': 'https://Stackoverflow.com/users/1677', 'pm_score': 4, 'selected': False, 'text': "<p>If you have .Net installed, a tool to generate XSD schemas and classes is already included by default.<br />\nFor me, the XSD tool is installed under the following structure. This may differ depending on your installation directory.</p>\n\n<pre><code>C:\\Program Files\\Microsoft Visual Studio 8\\VC&gt;xsd\nMicrosoft (R) Xml Schemas/DataTypes support utility\n[Microsoft (R) .NET Framework, Version 2.0.50727.42]\nCopyright (C) Microsoft Corporation. All rights reserved.\n\nxsd.exe -\n   Utility to generate schema or class files from given source.\n\nxsd.exe &lt;schema&gt;.xsd /classes|dataset [/e:] [/l:] [/n:] [/o:] [/s] [/uri:]\nxsd.exe &lt;assembly&gt;.dll|.exe [/outputdir:] [/type: [...]]\nxsd.exe &lt;instance&gt;.xml [/outputdir:]\nxsd.exe &lt;schema&gt;.xdr [/outputdir:]\n</code></pre>\n\n<p>Normally the classes and schemas that this tool generates work rather well, especially if you're going to be consuming them in a .Net language</p>\n\n<p>I typically take the XML document that I'm after, push it through the XSD tool with the <code>/o:&lt;your path&gt;</code> flag to generate a schema (xsd) and then push the xsd file back through the tool using the <code>/classes /L:VB (or CS) /o:&lt;your path&gt;</code> flags to get classes that I can import and use in my day to day .Net projects</p>\n"}, {'answer_id': 88695, 'author': 'Andreas Petersson', 'author_id': 16542, 'author_profile': 'https://Stackoverflow.com/users/16542', 'pm_score': 3, 'selected': False, 'text': '<p>if you are working in the java world - <em>intelliJ idea</em> has also extensive xml support, including xsd generation and samle xml from xsd generation, and with plugins you can get  xslt debuggers. - especially nice if you plan to use tools such as jaxb afterwards.</p>\n'}, {'answer_id': 184070, 'author': 'Dario', 'author_id': 11583, 'author_profile': 'https://Stackoverflow.com/users/11583', 'pm_score': 6, 'selected': False, 'text': '<p>You can use an open source and cross-platform option: inst2xsd from <a href="http://xmlbeans.apache.org/" rel="noreferrer">Apache\'s XMLBeans</a>. I find it very useful and easy.</p>\n\n<p>Just download, unzip and play (it requires Java).</p>\n'}, {'answer_id': 1236639, 'author': 'Derferman', 'author_id': 129012, 'author_profile': 'https://Stackoverflow.com/users/129012', 'pm_score': 6, 'selected': False, 'text': '<p><a href="http://www.thaiopensource.com/relaxng/trang.html" rel="noreferrer">Trang</a> is the best option here. Open source and cross platform (although Java is required)</p>\n<p>From the Trang Website:</p>\n<blockquote>\n<p>Trang converts between different schema languages for XML. It supports the following languages</p>\n<ul>\n<li>RELAX NG (XML syntax)</li>\n<li>RELAX NG compact syntax</li>\n<li>XML 1.0 DTDs</li>\n<li>W3C XML Schema</li>\n</ul>\n<p>A schema written in any of the supported schema languages can be converted into any of the other supported schema languages, except that W3C XML Schema is supported for output only, not for input.</p>\n<p><strong>Trang can also infer a schema from one or more example XML documents.</strong></p>\n</blockquote>\n<p><a href="https://github.com/relaxng/jing-trang" rel="noreferrer">Download Link</a></p>\n'}, {'answer_id': 8397984, 'author': 'edorian', 'author_id': 285578, 'author_profile': 'https://Stackoverflow.com/users/285578', 'pm_score': 4, 'selected': False, 'text': '<p>There also is <a href="http://kore-nordmann.de/blog/0104_generating_xml_schemas_from_xml.html" rel="noreferrer"><strong><code>XML schema learner</code></strong></a> which is available on <a href="https://github.com/kore/XML-Schema-learner" rel="noreferrer">Github</a>.</p>\n\n<p>It can take <strong>multiple xml files</strong> and <strong>extract a common XSD from all of those files</strong>.</p>\n'}, {'answer_id': 11190143, 'author': 'Nathan Donnellan', 'author_id': 997216, 'author_profile': 'https://Stackoverflow.com/users/997216', 'pm_score': 4, 'selected': False, 'text': '<p>In VS2010 if you load an XML file into the editor, click the XML menu >> Create Schema.</p>\n'}, {'answer_id': 18034165, 'author': 'v_e', 'author_id': 1935216, 'author_profile': 'https://Stackoverflow.com/users/1935216', 'pm_score': 2, 'selected': False, 'text': '<p>This is an old thread but I thought it could be useful to post this link: just found this tool:\n<a href="https://github.com/wiztools/xsd-gen" rel="nofollow">xsd-gen Generate XML Schema from XML</a></p>\n\n<p>and it just did what I needed.</p>\n'}]
['https://Stackoverflow.com/questions/74879', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/863/']