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

How Do I...? Common Tasks QuickStart Tutorial

Go To...

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.

C# XmlSchemaValidator.exe
View Source

[This sample can be found at M:\web\users\Sites\AspnetQuickStart\v2.0\QuickStart\howto\samples\Xml\XmlSchemaValidator\
To build this sample, open the SDK command prompt and navigate to the above path. Build the sample using the build tool msbuild passing the solution file as the first parameter: msbuild mySample.sln. The compiled executable will be found in the sub directory \bin directory.]

		
XmlSerializer serializer = new XmlSerializer(typeof(books));
Books myBooks = (books)serializer.Deserialize(reader);
...
XmlSchemaValidator xsv = CreateValidator();
xsv.Initialize(); 
			
xsv.ValidateElement("books", "http://www.example.com/my-bookshelf", schemaInfo);
...
C#



Microsoft .NET Framework SDK QuickStart Tutorials Version 2.0
Copyright � 2005 Microsoft Corporation. All rights reserved.


Hosted by MaximumASP | Found a broken link? | Contact Us | Terms and conditions | Privacy Policy | Advertise with us
� 2000 - 2008  Mindcracker LLC. All Rights Reserved