title: how to ask XSD.exe to generate proper class for me, so that i can create a fine XML
body: <p>I have created an XSD file from Visual Studio 2010,</p>
  
  <p>Then I use <code>xsd /c mydemo.xsd</code> to generate class for me, so that I can create a XML file at runtime.</p>
  
  <p>However, when I use that class, fill in some values, and serialize the object, the XML file does  not look nice to me.</p>
  
  <p>Here is my XSD file <a href="http://dl.dropbox.com/u/284185/demo.xsd" rel="nofollow">Click here to see</a></p>
  
  <p>What I expected the XML file to be is <a href="http://dl.dropbox.com/u/284185/expected-output.xml" rel="nofollow">Click here to see</a>
  (Generated from Visual Studio "Sample XML")</p>
  
  <p>But when I try to serialize it, the XML file is like this <a href="http://dl.dropbox.com/u/284185/output.xml" rel="nofollow">CLick here to see</a></p>
  
  <p>The format is totally different</p>
  
  <p>e.g</p>
  
  <p>Expecting:</p>
  
  <pre><code>&lt;ColumnInfo&gt; 
    &lt;Column Type="Type1" DisplayValue="DisplayValue1" Key="Key1"/&gt; 
    &lt;Column Type="Type2" DisplayValue="DisplayValue2" Key="Key2"/&gt; 
    &lt;Column Type="Type3" DisplayValue="DisplayValue3" Key="Key3"/&gt; 
  &lt;/ColumnInfo&gt;
  </code></pre>
  
  <p>but the generate result is like this:</p>
  
  <pre><code>&lt;columnInfoField&gt;
    &lt;ColumnType&gt;
      &lt;displayValueField&gt;Display value for key 1&lt;/displayValueField&gt;
      &lt;keyField&gt;key1&lt;/keyField&gt;
      &lt;typeField&gt;string&lt;/typeField&gt;
    &lt;/ColumnType&gt;
    &lt;ColumnType&gt;
      &lt;displayValueField&gt;Display value for key 2&lt;/displayValueField&gt;
      &lt;keyField&gt;key2&lt;/keyField&gt;
      &lt;typeField&gt;int&lt;/typeField&gt;
    &lt;/ColumnType&gt;
    &lt;ColumnType&gt;
      &lt;displayValueField&gt;Display value for key 3&lt;/displayValueField&gt;
      &lt;keyField&gt;key3&lt;/keyField&gt;
      &lt;typeField&gt;long&lt;/typeField&gt;
    &lt;/ColumnType&gt;
  &lt;/columnInfoField&gt;
  </code></pre>
  
  <p>And the code I implement to serialize the report is :</p>
  
  <p><a href="http://msdn.microsoft.com/en-us/library/ms731073.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms731073.aspx</a></p>
  
  <pre><code>DataContractSerializer dcs = new DataContractSerializer(typeof(Report));
  using (XmlDictionaryWriter xdw = XmlDictionaryWriter.CreateTextWriter(File.Create(@"C:\demo\schema\output.xml"), Encoding.UTF8))
  {
    dcs.WriteObject(xdw, report);
  }
  </code></pre>
  
  <p>Not sure why I cannot use "XmlSerializer", when I use it, it will complain about cannot cast array type something...</p>
  
  <blockquote>
    <p>Unable to generate a temporary class (result=1).<br>
    error CS0030: Cannot convert type 'ColumnValueType[]' to
    'ColumnValueType'<br>
    error CS0029: Cannot implicitly convert type 'ColumnValueType' to
    'ColumnValueType[]'</p>
  </blockquote>
  
  <p>So, does anyone can give me some suggestion, how can i fix my XML format???</p>