title: Create XSD from XML in Code
body: <p>I am using this piece of code from <code>MSDN</code> to create an XSD from an XML</p>
  
  <pre><code>XmlReader reader = XmlReader.Create("contosoBooks.xml");
  XmlSchemaSet schemaSet = new XmlSchemaSet();
  XmlSchemaInference schema = new XmlSchemaInference();
  
  schemaSet = schema.InferSchema(reader);
  
  foreach (XmlSchema s in schemaSet.Schemas())
  {
     textbox.text = s.ToString();
  }
  </code></pre>
  
  <p>I want to output the .xsd based on my xml file. When I generate the .xsd file, the only content I get inside it is: <code>System.Xml.Schema.XmlSchema</code></p>
  
  <p>When I generate the XSD using Visual Studio option to create Schema, it comes out properly. However, I have over 150 xml docs that I need to create XSD for hence need a programmatic option. Can anyone help?</p>