ZURINET
asked on
ValidationEventArgs e to String
Hi all
I have the code below , which outputs the result of an xml Validaton.
The result print out 3 error position..
But the string varErrorMesages displays only one ..
How can I assign all the error messages to string.. and not just the last value.
I want to pass all the string generated by the error to the string varErrorMesages
I have the code below , which outputs the result of an xml Validaton.
The result print out 3 error position..
But the string varErrorMesages displays only one ..
How can I assign all the error messages to string.. and not just the last value.
I want to pass all the string generated by the error to the string varErrorMesages
static void inputXMLValidationEventHandler(object sender, ValidationEventArgs e)
{
if (e.Severity == XmlSeverityType.Warning)
{
Debug.Write("WARNING in XML Messages: ");
Debug.WriteLine(e.Message);
string varErrorMesages = String.Format("Line: {0}, Position: {1} \"{2}\"",e.Exception.LineNumber, e.Exception.LinePosition,e.Exception.Message);
WARNING in XML Messages: Could not find schema information for the element 'doc'.
WARNING in XML Messages: Could not find schema information for the element 'assembly'.
WARNING in XML Messages: Could not find schema information for the element 'name'.
WARNING in XML Messages: Could not find schema information for the element 'members'.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Your handler is invoked three times, for three different errors. Therefore the only way you can achieve what you want by creating a class level variable.
See guru_sami's comment.
See guru_sami's comment.
Debug.WriteLine(e.Message)
I wil suggest that you capture both e.Message and exception info in varErrorMesages.