title: There is no Unicode byte order mark. Cannot switch to Unicode
body: <p>I am writing an XML validator with XSD.</p>
  
  <p>Below is what I did, but when the validator reached the line <code>while (list.Read())</code> it gives me the error </p>
  
  <blockquote>
    <p>There is no Unicode byte order mark. Cannot switch to Unicode.</p>
  </blockquote>
  
  <p>Can anybody help me fix it?</p>
  
  <pre><code>public class Validator
      {
          public void Validate(string xmlString)
          {
              Boolean bRet = true;
              string xmlPath = @"C:\x.xml";
              string xsdPath = @"C:\general.xsd";
  
              XmlReaderSettings Settings = new XmlReaderSettings();
              Settings.Schemas.Add("", xsdPath);
              Settings.ValidationType = ValidationType.Schema;
              Settings.ValidationEventHandler += 
                 new ValidationEventHandler(SettingsValidationEventHandler);
  
              XmlReader list = XmlReader.Create(xmlPath, Settings);
              //StringBuilder output = new StringBuilder();
              while (list.Read()) 
              {
              }
              //File.WriteAllText(@"D:\Output.xml", output.ToString());
          }
          static void SettingsValidationEventHandler(object sender,
                                                     ValidationEventArgs e)
          {
              if (e.Severity == XmlSeverityType.Warning)
              {
                  MessageBox.Show( "WARNING: ");
                  MessageBox.Show(e.Message);
              }
              else if (e.Severity == XmlSeverityType.Error)
              {
                  MessageBox.Show("ERROR: ");
                  MessageBox.Show(e.Message);
              }
          }
      }
  </code></pre>
  
  <h2>XML</h2>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-16"?&gt;
  &lt;FlashList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xmlns:xsd="http://www.w3.org/2001/XMLSchema" vin="xxxxxxxxxxxxx"&gt;
    &lt;flash ECUtype="xxx" /&gt;
  &lt;/FlashList&gt;
  </code></pre>
  
  <h2>XSD</h2>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-16"?&gt;
  &lt;xs:schema attributeFormDefault="unqualified" 
             elementFormDefault="qualified"
             xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt;
    &lt;xs:element name="FlashList"&gt;
      &lt;xs:complexType&gt;
        &lt;xs:sequence&gt;
          &lt;xs:element name="flash" 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="ECUtype" use="optional"/&gt;
                &lt;/xs:extension&gt;
              &lt;/xs:simpleContent&gt;
            &lt;/xs:complexType&gt;
          &lt;/xs:element&gt;
          &lt;xs:element name="Error" 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:byte" name="code" 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:attribute type="xs:string" name="vin"/&gt;
      &lt;/xs:complexType&gt;
    &lt;/xs:element&gt;
  &lt;/xs:schema&gt;
  </code></pre>