title: XML Validation against XSD in PHP libxml
body: <p>I have created an xml like below</p>
  
  <pre><code>&lt;Request&gt;
      &lt;RequestType&gt;Logon&lt;/RequestType&gt;
      &lt;MobileId&gt;23424&lt;/MobileId&gt;
      &lt;Password&gt;123456Gg&lt;/Password&gt;
  &lt;/Request&gt;
  </code></pre>
  
  <p>and my xsd file is like below code</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;xsd:schema attributeFormDefault="unqualified" elementFormDefault="qualified" version="1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
  &lt;xsd:element name="Request" type="RequestType"/&gt;
  &lt;xsd:complexType name="RequestType"&gt;
      &lt;xsd:sequence&gt;
          &lt;xsd:element name="RequestType"&gt;
              &lt;xsd:simpleType&gt;
                  &lt;xsd:restriction base="xsd:string"&gt;
                      &lt;xsd:enumeration value="Logon"/&gt;
                  &lt;/xsd:restriction&gt;
              &lt;/xsd:simpleType&gt;
          &lt;/xsd:element&gt;
          &lt;xsd:element name="MobileId" &gt;
              &lt;xsd:simpleType&gt;
                  &lt;xsd:restriction base="xsd:string"&gt;
                      &lt;xsd:minLength value="0" /&gt;
                      &lt;xsd:maxLength value="10" /&gt;
                  &lt;/xsd:restriction&gt;
              &lt;/xsd:simpleType&gt;
          &lt;/xsd:element&gt;
          &lt;xsd:element name="Password"&gt;
              &lt;xsd:simpleType&gt;
                  &lt;xsd:restriction base="xsd:string"&gt;
                      &lt;xsd:minLength value="0"/&gt;
                      &lt;xsd:maxLength value="255"/&gt;
                  &lt;/xsd:restriction&gt;
              &lt;/xsd:simpleType&gt;
          &lt;/xsd:element&gt;
      &lt;/xsd:sequence&gt;
  &lt;/xsd:complexType&gt;
  &lt;/xsd:schema&gt;
  </code></pre>
  
  <p>I have used PHP'S DOMDocument's schemaValidate function to validate the xml against the xsd, and it gives following error</p>
  
  <pre><code>Fatal Error 4: Start tag expected, '&lt;' not found on line 5 
  Error 1872: The document has no document element. on line 0
  </code></pre>
  
  <p>But I have tested those two files (xml and xsd) in this link <a href="http://www.utilities-online.info/xsdvalidation/#.UsqYpNIW2Fk" rel="noreferrer">W3C XML Schema Online validation</a>, and it successfully validates without showing any error. </p>
  
  <p>What I have to do to get work this in php?</p>
  
  <p>Note: my php libxml version is 2.7.8</p>