O
OpticTygre
How can I make the following code synchronous? TIA.
Public Sub ValidateXMLAgainstSchema(ByVal XSchema As XmlSchema, ByVal XData
As String)
Dim XSchemaset As XmlSchemaSet = New XmlSchemaSet
XSchemaset.Add(XSchema)
Dim XSettings As XmlReaderSettings = New XmlReaderSettings
XSettings.ValidationType = ValidationType.Schema
XSettings.Schemas = XSchemaset
Dim xStringReader As StringReader = New StringReader(XData)
Dim XReader As XmlReader = XmlReader.Create(xStringReader, XSettings)
AddHandler XSettings.ValidationEventHandler, AddressOf ValidationCallBack
While XReader.Read
'If there are errors, an asynchronous call would be made to the
'ValidationCallBack sub. How can we make this synchronous, so this
'sub can be made a function which would return a boolean, or a collection
'of ValidationEventArgs that we could return?
End While
End Sub
Private Shared Sub ValidationCallBack(ByVal sender As Object, ByVal e As
ValidationEventArgs)
MessageBox.Show("Error occurred. " & e.Message, "Validation Error",
MessageBoxButtons.OK, MessageBoxIcon.Error)
End Sub
Public Sub ValidateXMLAgainstSchema(ByVal XSchema As XmlSchema, ByVal XData
As String)
Dim XSchemaset As XmlSchemaSet = New XmlSchemaSet
XSchemaset.Add(XSchema)
Dim XSettings As XmlReaderSettings = New XmlReaderSettings
XSettings.ValidationType = ValidationType.Schema
XSettings.Schemas = XSchemaset
Dim xStringReader As StringReader = New StringReader(XData)
Dim XReader As XmlReader = XmlReader.Create(xStringReader, XSettings)
AddHandler XSettings.ValidationEventHandler, AddressOf ValidationCallBack
While XReader.Read
'If there are errors, an asynchronous call would be made to the
'ValidationCallBack sub. How can we make this synchronous, so this
'sub can be made a function which would return a boolean, or a collection
'of ValidationEventArgs that we could return?
End While
End Sub
Private Shared Sub ValidationCallBack(ByVal sender As Object, ByVal e As
ValidationEventArgs)
MessageBox.Show("Error occurred. " & e.Message, "Validation Error",
MessageBoxButtons.OK, MessageBoxIcon.Error)
End Sub