Eden Ridgway's Blog

.Net and Web Development Information

  Home :: Contact :: Syndication  :: Login
  105 Posts :: 1 Stories :: 78 Comments :: 3 Trackbacks

Search

Article Categories

Archives

Post Categories

Development

General

The xsd.exe .Net SDK utility is seemingly not well known. I knew that it could be used to generate an XSD from an XML example, but I had never used it to generate a serializable C# class. This turns out to be exactly what is needed on a project I'm currently working on.

To get the xsd utility (possibly found at C:\Program Files\Microsoft.NET\SDK\v1.1\Bin) to generate a class, uses the following command:

xsd.exe /c SourceSchema.xsd

The code it will generate will look something like this:

//------------------------------------------------------------------------------
// <autogenerated>
// This code was generated by a tool.
// Runtime Version: 1.1.4322.2032
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </autogenerated>
//------------------------------------------------------------------------------

//
// This source code was auto-generated by xsd, Version=1.1.4322.2032.
//
using System.Xml.Serialization;

/// <remarks/>
[System.Xml.Serialization.XmlRootAttribute(Namespace="", IsNullable=false)]
public class CreateApplication {

/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("CreatedApplications")]
public CreateApplicationOutput[] CreatedApplications;
}

/// <remarks/>
public class CreateApplicationOutput {

/// <remarks/>
public string Account;

/// <remarks/>
public object ApplicationID;
}

You should also read the following relevant articles:

posted on Tuesday, August 09, 2005 5:18 PM
Comments have been closed on this topic.