title: Validating an XML against referenced XSD in C#
body: <p>I have an XML file with a specified schema location such as this:</p>
  
  <pre><code>xsi:schemaLocation="someurl ..\localSchemaPath.xsd"
  </code></pre>
  
  <p>I want to validate in C#.  Visual Studio, when I open the file, validates it against the schema and lists errors perfectly.  Somehow, though, I can't seem to validate it automatically in C# without specifying the schema to validate against like so:</p>
  
  <pre><code>XmlDocument asset = new XmlDocument();
  
  XmlTextReader schemaReader = new XmlTextReader("relativeSchemaPath");
  XmlSchema schema = XmlSchema.Read(schemaReader, SchemaValidationHandler);
  
  asset.Schemas.Add(schema);
  
  asset.Load(filename);
  asset.Validate(DocumentValidationHandler);
  </code></pre>
  
  <p>Shouldn't I be able to validate with the schema specified in the XML file automatically ?  What am I missing ?</p>