I have an XmlSerializer object, and I have added 2 event handlers to the UnknownElement and UnknownAttribute events, as below:
XmlSerializer xs = new XmlSerialiser(typeof(MyClass));
xs.UnknownAttribute += new XmlAttributeEventHandler(xs_UnknownAttribute);
xs.UnknownElement += new XmlElementEventHandler(xs_UnknownAttribute);
Each of these event handlers basically do the same thing, they print out the node name or the attribute name causing the issue.
But for some reason, an InvalidOperationException is getting thrown saying there is an error in the xml document with . I thought these errors would be caught by my events?
Update
The exceptions are:
The exception is: Unhandled Exception: System.InvalidOperationException: There is an error in XML document (5, 110).
There is an InnerException of type XmlException, which states The 'MyTag' start tag on line 5 does not match the end tag of 'AnotherTag'. Line 5, position 110.