I have an XML file that is validated against an XSD file.
When a validation exception occurs, the handler is called:
ValidationCallBack(object sender, System.Xml.Schema.ValidationEventArgs args)
I have the exception thrown by the framework, but I need to customize this exception in order to have the XSD line that have thrown this error and also the value from the XML that was not correct.
Can I parse the exception’s message in order to extract this kind of information? I mean, can I rely on a regular expression for this?
I have found the solution, by using the xmlns:ex=”anySchemaNamespace” attribute for the xsd document element. Then, I can add for example this unhandled attribute ex:exception=”My custom exception” to any element and then take that custom exception message from the element in code, when an exception occurs.
Thanks for your answers.