title: C# - Parsing XSD schema - get all elements to combobox
body: <p>I have XSD Schema file and i need to fill my combobox with the elements from the schema file... </p>
  
  <pre><code>&lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt;
     &lt;xs:element name="auto"&gt;
        &lt;xs:complexType&gt;
           &lt;xs:sequence&gt;
              &lt;!-- Znacka --&gt;
              &lt;xs:element name="znacka" type="xs:string"/&gt;
              &lt;!-- pocetOsob --&gt;
              &lt;xs:element name="pocetOsob" type="xs:int"/&gt;
              &lt;!-- maxRychlost --&gt;
              &lt;xs:element name="maxRychlost"&gt;
                 &lt;xs:complexType&gt;
                    &lt;xs:simpleContent&gt;
                       &lt;xs:extension base="xs:decimal"&gt;
                          &lt;xs:attribute name="jednotka" type="xs:string"/&gt;
                       &lt;/xs:extension&gt;
                    &lt;/xs:simpleContent&gt;
                 &lt;/xs:complexType&gt;
              &lt;/xs:element&gt;
              &lt;!-- Motor --&gt;
              &lt;xs:element name="motor"&gt;
                 &lt;xs:complexType&gt;
                    &lt;xs:sequence&gt;
                       &lt;xs:element name="vykon"&gt;
                          &lt;xs:complexType&gt;
                             &lt;xs:simpleContent&gt;
                                &lt;xs:extension base="xs:decimal"&gt;
                                   &lt;xs:attribute name="jednotka" type="xs:string"/&gt;
                                &lt;/xs:extension&gt;
                             &lt;/xs:simpleContent&gt;
                          &lt;/xs:complexType&gt;
                       &lt;/xs:element&gt;
                    &lt;/xs:sequence&gt;
                    &lt;xs:attribute name="vyrobni_cislo" type="xs:string"/&gt;
                 &lt;/xs:complexType&gt;
              &lt;/xs:element&gt;
           &lt;/xs:sequence&gt;
        &lt;/xs:complexType&gt;
     &lt;/xs:element&gt;
  &lt;/xs:schema&gt; 
  </code></pre>
  
  <p>Anyone had idea how to do it? Through xpath? 
  I have a half working code... I got a message with element auto.</p>
  
  <pre><code>String path = openSchema.FileName;
  XmlTextReader xsd_file = new XmlTextReader(path);
  XmlSchema schema = new XmlSchema();
  schema = XmlSchema.Read(xsd_file, null);
  
  MessageBox.Show(schema.Items.Count.ToString());
  
  foreach (XmlSchemaElement element in schema.Items)
  {
      elements.Items.Add(element.Name);
      MessageBox.Show(element.Name);
  }
  </code></pre>
  
  <p>Thank you very much!</p>