1.  Imports System.Xml

2.  Imports System.Xml.Schema

3. 

4. 

5.  Public Class Form1

6. 

7.      Dim strMessage As String

8. 

9.      Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

10.         Dim doc As New XmlDocument

11.         doc.Load("C:\XML L8 Finished\Validator\recipes.xml")

12.

13.         doc.Schemas.Add("", "C:\XML L8 Finished\Validator\recipes.xsd")

14.

15.         Dim eventHandler As ValidationEventHandler = New ValidationEventHandler(AddressOf ValidationEventHandler)

16.

17.         doc.Validate(eventHandler)

18.

19.         If strMessage = "" Then strMessage = "Validated. No errors found."

20.

21.         MsgBox(strMessage)

22.

23.         End

24.

25.

26.     End Sub

27.

28.     Private Sub ValidationEventHandler(ByVal sender As Object, ByVal e As ValidationEventArgs)

29.

30.         strMessage += e.Message & vbCrLf & vbCrLf

31.

32. End Sub

33.

34. End Class