Consider: http://www.15seconds.com/Issue/021022.htm
-----Original Message----- From: Moderated discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED]] On Behalf Of Thaer Sent: Sunday, February 16, 2003 7:58 AM To: [EMAIL PROTECTED] Subject: [ADVANCED-DOTNET] XML Validation by XSD Hi, Iam a Java/C# developer, want to ask you about the following: I create a sample to Validate XML file by XML Schema (XSD file), Here is a snapshot from my code so as to let you know about my problem: class Class1 { static XmlTextReader r = null; static XmlValidatingReader v = null; private static bool isValid = true; // If a validation error occurs, public static void Main(string[] args) { r = new XmlTextReader(@"Product.xml"); v = new XmlValidatingReader(r); v.ValidationType = ValidationType.Schema; // XSD validation v.ValidationEventHandler += new ValidationEventHandler(MyValidationEventHandler); while (v.Read()) { } v.Close(); // Check whether the document is valid or invalid. if (isValid) { Console.WriteLine("\n\nDocument is valid"); } else { Console.WriteLine("\n\nDocument is invalid"); } Console.ReadLine(); } public static void MyValidationEventHandler(object sender, ValidationEventArgs args) { isValid = false; Console.WriteLine("Validation event\n" + args.Message); } } Taking the above into consideration, when I enter a valid XML file with Valid XSD file, the output will be "Document is valid". So every thing is good, but when enter an InValid XML (i.e. the XML data has more than one error in its data types according to XSD file), only the first error will be reported by XML validator, so what is the right way to let the XML validator to go through all the errors in XML and reporting them all. Thanks.
