title: c# XML DTD validation. ENTITY is an unexpected token
body: <p>Im trying to validate an XML file using a .DTD but it gives me the following error.</p>
  
  <blockquote>
    <p>'ENTITY' is an unexpected token. The expected token is 'DOCTYPE'. Line 538, position 3.</p>
  </blockquote>
  
  <pre><code>        public static void Validate(string xmlFilename, string schemaFilename)
      {
          XmlTextReader r = new XmlTextReader(xmlFilename);
          XmlValidatingReader validator = new XmlValidatingReader(r);
          validator.ValidationType = ValidationType.Schema;
  
          XmlSchemaCollection schemas = new XmlSchemaCollection();
          schemas.Add(null, schemaFilename);
  
  
          validator.ValidationEventHandler += new ValidationEventHandler(ValidationEventHandler);
  
          try
          {
              while (validator.Read())
              { }
          }
          catch (XmlException err)
          {
              Console.WriteLine(err.Message);
          }
          finally
          {
              validator.Close();
          }
      }
  </code></pre>
  
  <p>The DTD im using to validate = <a href="http://www.editeur.org/onix/2.1/reference/onix-international.dtd" rel="nofollow noreferrer">http://www.editeur.org/onix/2.1/reference/onix-international.dtd</a></p>
  
  <p>I hope someone can help me thanks!</p>