I am using XmlValidatingReader object to validat my object against a xsd schema but this class is obsolete in .NEt 2.0. Does any one have the right code to use the new Vaildation classes.
Yes:
XmlReaderSettings settings = new XmlReaderSettings();
settings.ValidationType = ValidationType.Schema;
settings.Schemas.Add ( .... );
settings.ValidationEventHandler += delegate( object sender, ValidationEventArgs e )
{
Console.WriteLine("invalid: " + e.Message);
};
XmlReader reader = XmlReader.Create (new XmlTextReader(file), settings);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With