How Do I...Validate XML using the XmlSchemaValidator Class?
This sample illustrates how to validate XML data by using the XmlSchemaValidator class. The
XmlSchemaValidator class is useful in advanced scenarios. It lets you validate an XML infoset
in-place without having to serialize it as an XML document, and then reparse the document by using a validating
XML reader. The sample deserializes XML data by using the XmlSerializer class, and then passes the XML data to
the methods of the XmlSchemaValidator class.
VB XmlSchemaValidator.exe
Dim serializer As New XmlSerializer(GetType(books))
Dim myBooks As Books = CType(serializer.Deserialize(reader), Books)
...
Dim xsv As XmlSchemaValidator = CreateValidator()
xsv.Initialize()
xsv.ValidateElement("books", "http://www.example.com/my-bookshelf", schemaInfo)
...
VB
Microsoft .NET Framework SDK QuickStart Tutorials Version 2.0
Copyright � 2005 Microsoft Corporation. All rights reserved.
|