I´m validating a XML file against a schema xsd. So far so good, the code generates a exception in case of failure.
bool isValid = true; List<string> errorList = new List<string>(); try { XmlReaderSettings settings = new XmlReaderSettings(); settings.Schemas.Add(null, schemaFilePath); settings.ValidationType = ValidationType.Schema; XmlDocument document = new XmlDocument(); document.LoadXml(xml); XmlReader rdr = XmlReader.Create(new StringReader(document.InnerXml), settings); while (rdr.Read()) { } } catch (Exception ex) { errorList.Add(ex.Message); isValid = false; } LogErrors(errorList); return isValid; But I need that the code build a list of all errors found in the validate before send it to my log, instead of always show only the first one found.
Any thoughts?
falsewhen it encounters the first error, but you don't even know what the error is!