title: "The element 'X' has invalid child element 'Y'. List of possible elements expected: 'Z'."
body: <p>I am a bit new here and learning XSD Schema. I have a function which uploaded XML file, first it upload the schema then when it upload XML file it throws this exception:</p>
  
  <p><code>"The element 'X' has invalid child element 'Y'. List of possible elements expected: 'Z'."</code></p>
  
  <p>This is my XSD file:</p>
  
  <pre><code>&lt;xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt;
    &lt;xs:element name="survey"&gt;
      &lt;xs:complexType&gt;
        &lt;xs:sequence&gt;
          &lt;xs:element type="xs:string" name="***"/&gt;
          &lt;xs:element name="questions"&gt;
            &lt;xs:complexType&gt;
              &lt;xs:sequence&gt;
                &lt;xs:element name="X" maxOccurs="unbounded" minOccurs="0"&gt;
                  &lt;xs:complexType&gt;
                    &lt;xs:sequence&gt;
                         &lt;xs:complexType&gt;
                          &lt;xs:sequence&gt;
                            &lt;xs:element name="option" maxOccurs="unbounded" minOccurs="0"&gt;
                              &lt;xs:complexType&gt;
                                &lt;xs:simpleContent&gt;
                                  &lt;xs:extension base="xs:string"&gt;
                                    &lt;xs:attribute type="xs:string" name="***" use="optional"/&gt;
                                  &lt;/xs:extension&gt;
                                &lt;/xs:simpleContent&gt;
                              &lt;/xs:complexType&gt;
                            &lt;/xs:element&gt;
                          &lt;/xs:sequence&gt;
                        &lt;/xs:complexType&gt;
                      &lt;/xs:element&gt;
                      &lt;xs:element name="Y" minOccurs="0"&gt;
                        &lt;xs:complexType&gt;
                          &lt;xs:sequence&gt;
                            &lt;xs:element name="Z"&gt;
                              &lt;xs:complexType&gt;
                                &lt;xs:sequence&gt;
                                  &lt;xs:element name="***" maxOccurs="unbounded" minOccurs="0"&gt;
                                    &lt;xs:complexType&gt;
                                      &lt;xs:simpleContent&gt;
                                        &lt;xs:extension base="xs:byte"&gt;
                                          &lt;xs:attribute type="xs:string" name="***" use="optional"/&gt;
                                        &lt;/xs:extension&gt;
                                      &lt;/xs:simpleContent&gt;
                                    &lt;/xs:complexType&gt;
                                  &lt;/xs:element&gt;
                                &lt;/xs:sequence&gt;
                              &lt;/xs:complexType&gt;
                            &lt;/xs:element&gt;
                          &lt;/xs:sequence&gt;
                          &lt;xs:attribute type="xs:string" name="***" use="optional"/&gt;
                          &lt;xs:attribute type="xs:string" name="***" use="optional"/&gt;
                          &lt;/xs:complexType&gt;
                      &lt;/xs:element&gt;
                      &lt;xs:element name="Z" minOccurs="0"&gt;
                      &lt;xs:complexType&gt;
                        &lt;/xs:complexType&gt;
                      &lt;/xs:element&gt;
                    &lt;/xs:sequence&gt;
                  &lt;/xs:complexType&gt;
                &lt;/xs:element&gt;
              &lt;/xs:sequence&gt;
            &lt;/xs:complexType&gt;
          &lt;/xs:element&gt;
          &lt;xs:element name="***"&gt;
            &lt;xs:complexType&gt;
              &lt;xs:sequence&gt;
              &lt;/xs:sequence&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>I have read similar posts, some are suggesting to change <code>&lt;xs:sequence&gt;</code> to <code>&lt;xs:all&gt;</code>; I have done this but is not working. Other are suggesting to add <code>elementFormDefault="qualified"</code> attribute  in root element ` but it is also not working.</p>
  
  <p>I am still not understanding what is the real problem.</p>
  
  <p>Any suggestion would be helpful.</p>