title: How to use Complex types with xs:any / ##any and mixed in code generated by the XSD tool
body: <p>I have the following complex type in my XML schema:</p>
  
  <pre><code>&lt;xs:complexType name="Widget" mixed="true"&gt;
      &lt;xs:sequence&gt;
          &lt;xs:any namespace="##any" processContents="skip" minOccurs="0" maxOccurs="unbounded"/&gt;
      &lt;/xs:sequence&gt;
  &lt;/xs:complexType&gt;
  </code></pre>
  
  <p>The element in derived XML could contain string or could contained wellformed XML, hence the mixed attribute being true.</p>
  
  <p>When I run this through the .NET XSD Tool I get the following generate code:</p>
  
  <pre><code>public partial class Widget{
  
      private System.Xml.XmlNode[] anyField;
  
      /// &lt;remarks/&gt;
      [System.Xml.Serialization.XmlTextAttribute()]
      [System.Xml.Serialization.XmlAnyElementAttribute()]
      public System.Xml.XmlNode[] Any {
          get {
              return this.anyField;
          }
          set {
              this.anyField = value;
          }
      }
  }
  </code></pre>
  
  <p>The question I have is that I am not entirely sure how I should then use this.  Ultimately I need to be able to set the value of widget to either:</p>
  
  <pre><code>&lt;widget&gt;Hello World!&lt;/widget&gt;
  </code></pre>
  
  <p>or</p>
  
  <pre><code>&lt;widget&gt;
    &lt;foo&gt;Hello World&lt;/foo&gt;
  &lt;/widget&gt;
  </code></pre>
  
  <p>Both of which validate agaisnt the schema</p>