Using ValidationEventHandler : Xml Validation « XML « C# / CSharp Tutorial






using System;
using System.IO;
using System.Xml.Schema;

public class ValidateSchema {
  public static void Main(string [] args) {
    ValidationEventHandler handler = new ValidationEventHandler(ValidateSchema.Handler);
    XmlSchema schema = XmlSchema.Read(File.OpenRead(args[0]),handler);
    schema.Compile(handler);
  }

  public static void Handler(object sender, ValidationEventArgs e) {
    Console.WriteLine(e.Message);
  }
}








30.19.Xml Validation
30.19.1.Validate Xml
30.19.2.Using ValidationEventHandler
30.19.3.Check for different Xml validation error level