7.13. Create a Schema for a .NET Class

Problem

You need to create an XML schema based on one or more VB .NET classes. This will allow you to validate XML documents before deserializing them with the XmlSerializer.

Solution

Use the XML Schema Definition Tool (xsd.exe) command-line utility included with the .NET Framework. Specify the name of your assembly as a command-line argument, and add the /t:[TypeName] parameter to indicate the types for which you want to generate a schema.

How It Works

Recipe 7-12 demonstrated how to use the XmlSerializer to serialize .NET objects to XML and deserialize XML into .NET objects. But if you want to use XML as a way to interact with other applications, business processes, or non-.NET Framework applications, ...

Get Visual Basic 2008 Recipes: A Problem-Solution Approach now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.