title: What is the best way to create an XML document conforming to an XSD Schema?
body: <p>I have an XSD and I have to generate an XML document to send to the customers of the company I work with. The documents I send will be validated against this XSD schema.</p>
  
  <p>What is the best way to create a XML document conforming to a XSD Schema? I mean, I'm searching for best practices and the like. I'm new to this and while "Googling" around here and there, I found people using XmlTextWriter, DataSet.WriteXml, and others.</p>
  
  <ol>
  <li><p>DataSet.WriteXml seems to not work well for me. This is what I did:</p>
  
  <pre><code>var ds = new DataSet();
  ds.ReadXmlSchema(schemaFile);
  ds.Tables["TableName"].Rows.Add("", "", 78, true, DateTime.Now);
  ...
  ds.WriteXml("C:\\xml.xml");
  </code></pre>
  
  <p>I found it generates a node with NewDataSet, and the nodes are not in the proper order.</p></li>
  <li><p>XmlTextWriter, I find it a bit long to do... but I will if there is no other choice.</p></li>
  </ol>
  
  <p>What do you think is the best way to do this? Are there other approaches to do it?
  I would put the schema here if it wasn't so long, and if it were relevant to the question.</p>