First, I need a class to convert, so I will generate an XSD file from this class, which resides inside of an assembly called MyClassLibrary.dll:
Next, a command prompt window is opened in the same directory as MyClassLibrary.dll.
using System.Xml.Serialization;
namespace MyNameSpace
{
[XmlRoot("Customer", Namespace ="http://www.yates.com/BusinessObjects/2007/07")]
public class Customer
{
private string _firstName;
private string _middleName;
private string _lastName;
public string LastName
{
get { return _lastName; }
set { _lastName = value; }
}
public string FirstName
{
get { return _firstName; }
set { _firstName = value; }
}
public string MiddleName
{
get { return _middleName; }
set { _middleName = value; }
}
[XmlIgnore]
public string Name
{
get
{
if (string.IsNullOrEmpty(MiddleName) == false)
return string.Format("{0} {1} {2}", FirstName, MiddleName, LastName);
else return string.Format("{0} {1}", FirstName, LastName);
}
}
}
}
Afterwards, the following command is used to generate the XSD:
"C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\xsd.exe" MyClassLibrary.dll /t:Customer

Finally, an XSD file called schema0.xsd is generated in the same directory as the assembly. It looks like this: