XML validation

Nov 3, 2008 at 6:14 PM
Can somebody tell me how to handle fixing XML validation errors?
In my code, I call 

xmlDoc.Validate(Schemas_ValidationEventHandler);

in my main method. This calls the below eventhandler for each validation error. Based on the error type, i want to be able to perform various actions on the problematic node (example: delete the node)


static

void Schemas_ValidationEventHandler(object sender, ValidationEventArgs e) {

 

 

System.Xml.Schema.

 

 

XmlSchemaValidationException ex = (XmlSchemaValidationException)e.Exception;

 //I want to delete the node 'ex.SourceObject' if the content is empty.
//How do I get the document node??

 

 }