Schema with Entity -- Validating Error
-
Hi, I wrote a Schema Validator in C#.NET. XmlTextReader R = new XmlTextReader(FileToParse); XmlValidatingReader V = new XmlValidatingReader(R); try { XmlSchemaCollection xsc = new XmlSchemaCollection(); xsc.Add("", SchemaFile); V.Schemas.Add(xsc); V.EntityHandling = EntityHandling.ExpandEntities; V.ValidationEventHandler += new ValidationEventHandler(ShowValidationErrors); while (V.Read()) { } //V.Close(); //MessageBox.Show("Validation Completed"); //R.Close(); } catch (XmlException xe) { //Display exceptions } catch (XmlSchemaException xse) { //Display exceptions } catch (Exception ee) { //Display exceptions } finally { V.Close(); MessageBox.Show("Validation Completed"); } This works fine if the xml file DOES NOT contain entity declarations. But, If the xml file contains any entity declaration (as below), the 'ValidationEventHandler' throws errors like "Validation Error: The 'mytest' element is not declared.Line : 8 Position : 2" "Validation Error: The 'articles' element is not declared.Line : 9 Position : 2", etc..... How do I overcome this in C#.NET ]>