Page view counter

These tutorials demonstrate selected features in ASP.NET version 2.0, but they are compatible with later versions of ASP.NET as well. For the current documentation, see the ASP.NET portal on the MSDN Web site.

 

 

   Welcome   |   ASP.NET   |   Web Services   |   Class Browser   
  |   I want my samples in...      

How Do I...? Common Tasks QuickStart Tutorial

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
View Source

		
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.