<p>In Visual Studio you can create a template XML document from an existing schema. The new <a href="http://msdn.microsoft.com/en-us/library/cc716766.aspx" rel="noreferrer">XML Schema Explorer</a> in VS2008 SP1 takes this a stage further and can create a sample XML document complete with data.
Is there a class library in .NET to do this automatically without having to use Visual Studio? I found the <a href="http://msdn.microsoft.com/en-us/library/aa302296.aspx" rel="noreferrer">XmlSampleGenerator</a>  article on MSDN but it was written in 2004 so maybe there is something already included in .NET to do this now?</p>

[{'answer_id': 174148, 'author': 'curtisk', 'author_id': 17651, 'author_profile': 'https://Stackoverflow.com/users/17651', 'pm_score': 0, 'selected': False, 'text': '<p>Directly, none that I can think of, other than third party add-ons. You could utilize the <a href="http://msdn.microsoft.com/en-us/library/x6c1kb0s(VS.80).aspx" rel="nofollow noreferrer">xsd schema definition tool</a> to take your XSD and create a .NET object/class, once you have that, you could, to quote the linked page: </p>\n\n<blockquote>\n  <p>XSD to Classes: Generates runtime classes from an XSD schema file. The generated classes can be used in conjunction with <a href="http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlserializer(VS.80).aspx" rel="nofollow noreferrer">System.Xml.Serialization.XmlSerializer</a> to read and write XML code that follows the schema.</p>\n</blockquote>\n'}, {'answer_id': 245461, 'author': 'Andrew Theken', 'author_id': 32238, 'author_profile': 'https://Stackoverflow.com/users/32238', 'pm_score': 3, 'selected': False, 'text': '<p>some footwork is involved, but you could load the xsd into a DataSet object, iterate over the Tables and add a few rows in each by calling calling NewRow() on each and then adding those rows back into their respective tables.. then save the DataSet out to a file:</p>\n\n<pre><code>DataSet ds = new DataSet();\nds.ReadXmlSchema("c:/xsdfile.xsd");\n\nforeach(DataTable t in ds.Tables)\n{\nvar row = t.NewRow();\nt.Rows.Add(row);\n}\n\nds.WriteXml("c:/example.xml");\n</code></pre>\n\n<p>P.S. A little extra work, but instead of just iterating over each table type and adding empty rows, you could build a nice winform that would allow you to drop in some data for each of the rows. I built something like this in about an hour a few weeks ago.</p>\n'}, {'answer_id': 7797060, 'author': 'SoftwareSavant', 'author_id': 729820, 'author_profile': 'https://Stackoverflow.com/users/729820', 'pm_score': 1, 'selected': False, 'text': '<p>Have you tried <a href="http://xsd2code.codeplex.com/" rel="nofollow">http://xsd2code.codeplex.com/</a>????</p>\n\n<p>It worked for me, it can work for you.</p>\n'}]
['https://Stackoverflow.com/questions/41674', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3873/']