XmlTextReader xmltxtrdrImportXML = new XmlTextReader(opndlgImportXML.FileName); //XML file was selected in open file dialog xmlvldrdrImportXML = new XmlValidatingReader(xmltxtrdrImportXML); XmlSchemaCollection xmlschcolImportXML = new XmlSchemaCollection(); //You miss namespace (it must be the same for schema and XML file) - you must specify it when adding schema to the collection //ConfigurationSettings.AppSettings["XMLSchemaLocation"] holds physical path to the schema xmlschcolImportXML.Add("http://tempuri.org/dstExchange.xsd", new XmlTextReader(ConfigurationSettings.AppSettings["XMLSchemaLocation"])); xmlvldrdrImportXML.Schemas.Add(xmlschcolImportXML); xmlvldrdrImportXML.ValidationType = ValidationType.Schema; xmlvldrdrImportXML.ValidationEventHandler += new ValidationEventHandler(ValidationError); //ValidationError is handler for errors, which will be called when validation error was occured. //Next code replaces your cycle for reader to read whole file //It simply tries to load XML file into dataset, instanced from the same schema dstExchange dstTestImport = new dstExchange(); dstTestImport.ReadXml(xmlvldrdrImportXML, XmlReadMode.IgnoreSchema);In original procedure I was used flag to track whether validation errors was occured. If none, I was loaded XML file into second, real dataset (also instanciated from the same schema) without validating.
Plamen Ivanov
MCSD .NET Early Achiever and MCAD .NET Charter Member (VB .NET/SQL Server 2000)
MCSD (VB 6.0/SQL Server 2000) br>
VB (.NET) - what other language do you need in the whole Universe?...