validate XML File against inline Schema

”’ <summary>
”’ validates XML File against inline Schema
”’ </summary>
”’ <param name=”sXmlFile”>xml File mit Schema und Daten</param>
”’ <returns>true no errors, false errors</returns>
”’ <remarks>not used, not ready</remarks>
”’
Public Function ValidateXMLFileInternalXSD(ByVal sXmlFile As String) As Boolean
Try
Dim oXmlReaderSettings As New XmlReaderSettings()
oXmlReaderSettings.ValidationType = ValidationType.Schema
oXmlReaderSettings.ValidationFlags = oXmlReaderSettings.ValidationFlags Or XmlSchemaValidationFlags.ProcessInlineSchema
oXmlReaderSettings.ValidationFlags = oXmlReaderSettings.ValidationFlags Or XmlSchemaValidationFlags.ReportValidationWarnings
AddHandler oXmlReaderSettings.ValidationEventHandler, AddressOf oXmlReaderSettingsValidationEventHandler
Dim reader As XmlReader = XmlReader.Create(sXmlFile, oXmlReaderSettings)
‘ parse reader
While (reader.Read())
End While
Catch ex As XmlException
Console.WriteLine(“XmlDocumentValidationExample.XmlException: {0}”, ex.Message)
Return False
Catch ex As XmlSchemaValidationException
Console.WriteLine(“XmlDocumentValidationExample.XmlSchemaValidationException: {0}”, ex.Message)
Return False
Catch ex As Exception
Console.WriteLine(“XmlDocumentValidationExample.Exception: {0}”, ex.Message)
Return False
End Try
Return True
End Function

..:: Whereever you go, stay in touch. Download toolbar now! It´s free, private and secure. ::..

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s