I set up my Xml validation like this...
XmlTextReader xrdr = new XmlTextReader(tempFile);
XmlValidatingReader xvr = new XmlValidatingReader(xrdr);
xvr.ValidationType = ValidationType.Schema;
xvr.ValidationEventHandler += new ValidationEventHandler(FormValidationEventHandler);
while (xvr.Read())
{
}
And my FormValidationEventHandler(object sender, ValidationEventArgs args) event handler is simply trying to capture the most meaningful message for the user, which should include the failing Xml node's name and value, along with the exception message. However, when pausing the debugger in the event handler, only the internal variable $exception contains the specific node value in the message. The args.Message and args.Exception.Message both contain only the node name, which is not helpful enough. I have explored all the properties and methods of the sender and args, but have not found it.
Here is an example of the message currently available...
"The 'http://www.sec.gov/edgar/nmfpsecurities:InvestmentIssuer' element has an invalid value according to its data type."
Here is an example of the message in $exception...
"The value 'E.I. DU PONT DE NEMOURS & CO. ' is invalid according to its schema type 'http://www.sec.gov/edgar/invest:InvestmentIssuer' - line-feed (#xA) or tab (#x9) characters, leading or trailing spaces and sequences of one or more spaces (#x20) are not allowed in 'xs:token'."
I need to know how to either 1) access the failing node value given the sender and args, or 2) magically access the internal variable $exception inside my event handler. Thanks!