I have an xsd (greatly simplified for this post):
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="serviceResponse" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="serviceResponse" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="searchResults">
<xs:complexType>
<xs:sequence>
<xs:element name="numberOfResults" type="xs:string" minOccurs="0" />
<xs:element name="raceList" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="race" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="id" type="xs:string" minOccurs="0" />
<xs:element name="title" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
I need simple c# classes:
public class serviceResponse
{
public searchResults SearchResults { get; set; }
}
public class searchResults
{
public string numberOfResults { get; set; }
public List<race> raceList { get; set; }
}
public class race
{
public string id { get; set; }
public string title { get; set; }
}
I was told xsd.exe or even csxsd.exe can do this, but don't see the flags that just get simple usable classes out of those. I just need super simple classes that can be populated with xml from restful api calls. I do not want to hand code 150+ differenty object types. Is there a tool that does this?
Try Xsd2Code - free and available from CodePlex. Visual Studio Plugin to right-click on XSD and generate .cs file for it.
Update (May 2018):
Unfortunately, this tool is no longer available for free. You can find the new Xsd2Code website here and see the licensing options.

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With