In Visual Studio 2010 ASP.NET 4.0
I want to write a procedure to validate a xml file with a xsd. I found some examples on the web but the one i chose does not work as attended. The example uses XmlReader with a XmlReaderSettings and a ValidationEventHandler.
Here is the code
Protected Sub VerifyDes(ByVal filename As String)
Dim xslDes As XmlReaderSettings = New XmlReaderSettings()
xslDes.ValidationType = ValidationType.Schema
xslDes.ValidationFlags = XmlSchemaValidationFlags.ReportValidationWarnings
AddHandler xslDes.ValidationEventHandler, AddressOf xslDesValidationEventHandler
Dim des As XmlReader = XmlReader.Create(filename, xslDes)
Protected Sub xslDesValidationEventHandler(ByVal sender As Object, ByVal e As ValidationEventArgs)
'some code here
I tested this procedure with a xml file which was well formed but contained some elements which were not conform to the xsd.
No event or error occured. It said the file was valid.
Then i tested with a badly formed file. A XmlException was raised but nothing happened with the ValidationEventHandler.
It seems lik
View Complete Post