title: Getting null in nested elements when deserializing xml
body: <p>I'm deserializing my xml which is string, into my classes.
  Problem is that part of nested child elements or their attributes return null.</p>
  
  <p>Here is my deserialize function:</p>
  
  <pre><code>public static T DeSerialize&lt;T&gt;(this string xml)
  {
      XmlSerializer serializer = new XmlSerializer(typeof(T));
      using (TextReader reader = new StringReader(xml))
      {
          T result = (T)serializer.Deserialize(reader);
          return result;
      }
  }
  </code></pre>
  
  <p>Here are my classes:</p>
  
  <pre><code>[System.SerializableAttribute()]
  [System.Diagnostics.DebuggerStepThroughAttribute()]
  [System.ComponentModel.DesignerCategoryAttribute("code")]
  [System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://www.specifiedcompany.com/API")]
  public partial class VideoGames
  {
      private GameType[] typesField;
  
      private Platform platformField;
  
      private string memoField;
  
      [System.Xml.Serialization.XmlArray("Types", Order = 0)]
      [System.Xml.Serialization.XmlArrayItem("Data", IsNullable = false)]
      public GameType[] Types
      {
          get
          {
              return this.typesField;
          }
          set
          {
              this.typesField= value;
          }
      }
  
      [System.Xml.Serialization.XmlElementAttribute("Platform", Order = 1)]
      public Platform Platform
      {
          get
          {
              return this.platformField;
          }
          set
          {
              this.platformField= value;
          }
      }
  
      [System.Xml.Serialization.XmlAttributeAttribute()]
      public string Memo
      {
          get
          {
              return this.memoField;
          }
          set
          {
              this.memoField= value;
          }
      }
  }
  
  [System.SerializableAttribute()]
  [System.Diagnostics.DebuggerStepThroughAttribute()]
  [System.ComponentModel.DesignerCategoryAttribute("code")]
  [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "http://www.specifiedcompany.com/API")]
  public partial class Platform
  {
      private decimal compressedField;
  
      [System.Xml.Serialization.XmlAttributeAttribute()]
      public decimal Compressed
      {
          get
          {
              return this.compressedField;
          }
          set
          {
              this.compressedField= value;
          }
      }
  }
  
  [System.SerializableAttribute()]
  [System.Diagnostics.DebuggerStepThroughAttribute()]
  [System.ComponentModel.DesignerCategoryAttribute("code")]
  [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "http://www.specifiedcompany.com/API")]
  public partial class GameType
  {
      private Code[] codeField;
  
      private string nameField;
  
      [System.Xml.Serialization.XmlArrayAttribute("Code", Order = 0)] 
      [System.Xml.Serialization.XmlArrayItemAttribute("Category", IsNullable = false)]
      public Code[] Code
      {
          get
          {
              return this.codeField;
          }
          set
          {
              this.codeField= value;
          }
      }
  
      [System.Xml.Serialization.XmlAttributeAttribute()]
      public string Name
      {
          get
          {
              return this.nameField;
          }
          set
          {
              this.nameField= value;
          }
      }
  }
  
  [System.SerializableAttribute()]
  [System.Diagnostics.DebuggerStepThroughAttribute()]
  [System.ComponentModel.DesignerCategoryAttribute("code")]
  [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "http://www.specifiedcompany.com/API")]
  public partial class Code
  {
      private string textField;
  
      [System.Xml.Serialization.XmlAttributeAttribute()]
      public string Text
      {
          get
          {
              return this.textField;
          }
          set
          {
              this.textField= value;
          }
      }
  }
  </code></pre>
  
  <p>Here is the xml:</p>
  
  <pre><code>&lt;VideoGames Memo="1"&gt;
      &lt;Types&gt;
          &lt;Data Name="RPG"&gt;
              &lt;Code&gt;
                  &lt;Category Text="TestingData"/&gt;
              &lt;/Code&gt;
          &lt;/Data&gt;
      &lt;/Types&gt;
      &lt;Platform Compressed="3.2876"/&gt;
  &lt;/VideoGames&gt;
  </code></pre>
  
  <p>And I'm using deserialize like this:</p>
  
  <pre><code>string xml = "";//xml string above.
  VideoGames a = xml.DeSerialize&lt;VideoGames&gt;();
  </code></pre>
  
  <p>I expect every property in class will have value, but only Memo in VideoGames has value, others are null.</p>
  
  <p>For example: <code>a.Types</code> is null, but <code>a.Memo</code> is "1".</p>
  
  <p>I have tried all related questions searched by this topic, and none of them work.</p>
  
  <p>Note: </p>
  
  <pre><code>XmlDocument xDoc = new XmlDocument();
  xDoc.LoadXml(xml);
  </code></pre>
  
  <p>I have checked this xDoc, it loaded perfectly, nothing was lost.</p>