title: C# serializing xsi:type and xsd
body: <p>I have a schema defined as follows:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;xs:schema id="Books" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"&gt;
    &lt;xs:element name="Books" msdata:IsDataSet="true" msdata:Locale="en-US"&gt;
      &lt;xs:complexType&gt;
        &lt;xs:choice minOccurs="0" maxOccurs="unbounded"&gt;
          &lt;xs:element name="Book" type="MyBookType"&gt;&lt;/xs:element&gt;
        &lt;/xs:choice&gt;
      &lt;/xs:complexType&gt;
    &lt;/xs:element&gt;
  
    &lt;xs:complexType name="MyBookType"&gt;
    ...
    &lt;/xs:complexType&gt;
  
  &lt;/xs:schema&gt;
  </code></pre>
  
  <p>Using this schema and xsd.exe, I generate the classes that will be used during serialization.
  The class generated by the above schema produces the following xml when serialized:</p>
  
  <pre><code>&lt;Books&gt;
    &lt;Book&gt;
    ...
    &lt;/Book&gt;
  &lt;/Books&gt;
  </code></pre>
  
  <p>This xml is used in a SOAP request and the service on the other end expects the following xml:</p>
  
  <pre><code>&lt;Books&gt;
    &lt;Book xsi:type="MyBookType"&gt;
    ...
    &lt;/Book&gt;
  &lt;/Books&gt;
  </code></pre>
  
  <p>How can I edit my schema so that the xsi:type attribute is included in the serialized xml?</p>