Imports System
Imports System.Xml.Linq
Imports System.Xml.Schema
Public Class MainClass
Shared errors As Boolean = False
Private Shared Sub XSDErrors(ByVal o As Object, ByVal e As ValidationEventArgs)
Console.WriteLine("{0}", e.Message)
errors = True
End Sub
Public Shared Sub Main()
Dim schemas As XmlSchemaSet = New XmlSchemaSet()
schemas.Add("", "data.xsd")
Dim custOrd As XDocument = XDocument.Load("data.xml")
errors = False
custOrd.Validate(schemas, AddressOf XSDErrors)
Console.WriteLine(errors)
custOrd.Root.Element("Orders").Element("Order").Element("CustomerID").Value = "AAAAA"
errors = False
custOrd.Validate(schemas, AddressOf XSDErrors)
Console.WriteLine(errors)
End Sub
End Class