Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Imports System.IO
Imports System.Xml
Imports System.Xml.Schema
Imports Microsoft.VisualBasic
Private m_success As Boolean = true
Private txtreader As XmlTextReader = Nothing
Private reader As XmlValidatingReader = Nothing
Private Sub Validate(filename As String)
Try
'Implement the readers. Set the ValidationType.
txtreader = New XmlTextReader(filename)
reader = New XmlValidatingReader(txtreader)
' Leave .ValidationType as auto (the default)
Console.WriteLine(ControlChars.Cr & "Validating XML file " & filename.ToString())
m_success = True
'Set the validation event handler.
AddHandler reader.ValidationEventHandler, AddressOf ValidationCallBack
' Read XML data
While reader.Read()
End While
Console.WriteLine("Validation finished. Validation {0}", IIf(m_success, "successful", "failed"))
Finally
'Close the reader.
If Not (reader Is Nothing) Then
reader.Close()
End If
End Try
End Sub 'Validate
'Snag the validation errors.
Private Sub ValidationCallBack(sender As Object, args As ValidationEventArgs)
m_success = False
Console.Write(ControlChars.CrLf & ControlChars.Tab & "Validation error: " & args.Message)
End Sub 'ValidationCallBack
Dim xsc As New XmlSchemaCollection()
xsc.Add("", "someschema.xsd")
reader.Schemas.Add(xsc) '(reader is your validating reader from above)
' now read the XML data.