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: