<p>I have a web application that generates a medium sized XML dataset to be consumed by a third party.<br>
I thought it would be a good idea to provide some form of schema document for the XML that I generate so I pasted the XML into Visual Studio and got it to generate an XSD.<br>
The annoying thing is that my XML doesn't validate to the XSD that was generated!</p>

<p>Is it better to roll your own XSD?<br>
What about different schema docs like DTDs, Relax NG, or Schematron?  </p>

<p>The key is that I would like to be able to validate my document using C#. </p>

<p>What are your XML validation strategies?</p>

[{'answer_id': 16628, 'author': 'Vaibhav', 'author_id': 380, 'author_profile': 'https://Stackoverflow.com/users/380', 'pm_score': 0, 'selected': False, 'text': '<p>You will be able to validate your XML with either an XML Schema or a DTD using C#. DTDs are older standards as compared to XML Schemas.</p>\n\n<p>So, I recommend an XML Schema approach.</p>\n'}, {'answer_id': 16714, 'author': 'Nicholas Trandem', 'author_id': 765, 'author_profile': 'https://Stackoverflow.com/users/765', 'pm_score': 3, 'selected': False, 'text': '<p>Whether you choose XSD and/or Schematron depends on what you are trying to validate. XSD is probably the most common validation strategy, but there are limits on what it can validate. If all you want to do is ensure that the right type of data is in each field, XSD should work for you. If you need to assert, for example, that the value of the &lt;small> element is less than the value of the &lt;big> element, or even more complex business rules involving multiple fields, you probably want Schematron or a hybrid approach.</p>\n'}]
['https://Stackoverflow.com/questions/16611', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1894/']