title: XML deserialization stuck
body: <p>I've generated a xsd file from xml and then <code>priceResponse.cs</code> from xsd file using <code>xsd.exe</code>.</p>
  
  <p>Here is <code>priceResponse.cs</code> code:</p>
  
  <pre><code>using System.Xml.Serialization;
  
  // 
  // This source code was auto-generated by xsd, Version=4.6.1055.0.
  // 
  
  
  /// &lt;uwagi/&gt;
  [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.1055.0")]
  [System.SerializableAttribute()]
  [System.Diagnostics.DebuggerStepThroughAttribute()]
  [System.ComponentModel.DesignerCategoryAttribute("code")]
  [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
  [System.Xml.Serialization.XmlRootAttribute(Namespace="", IsNullable=false)]
  public partial class document {
  
      private object[] itemsField;
  
      /// &lt;uwagi/&gt;
      [System.Xml.Serialization.XmlElementAttribute("DATASETS", typeof(documentDATASETS), Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
      [System.Xml.Serialization.XmlElementAttribute("ERROR", typeof(documentERROR), Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
      [System.Xml.Serialization.XmlElementAttribute("PRICE", typeof(documentPRICE), Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
      public object[] Items {
          get {
              return this.itemsField;
          }
          set {
              this.itemsField = value;
          }
      }
  }
  
  /// &lt;uwagi/&gt;
  [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.1055.0")]
  [System.SerializableAttribute()]
  [System.Diagnostics.DebuggerStepThroughAttribute()]
  [System.ComponentModel.DesignerCategoryAttribute("code")]
  [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
  public partial class documentDATASETS {
  
      private string cOUNTRYField;
  
      private string cURRENCYField;
  
      private string pOSTCODEMASKField;
  
      private string tOWNGROUPField;
  
      private string sERVICEField;
  
      private string oPTIONField;
  
      /// &lt;uwagi/&gt;
      [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
      public string COUNTRY {
          get {
              return this.cOUNTRYField;
          }
          set {
              this.cOUNTRYField = value;
          }
      }
  
      /// &lt;uwagi/&gt;
      [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
      public string CURRENCY {
          get {
              return this.cURRENCYField;
          }
          set {
              this.cURRENCYField = value;
          }
      }
  
      /// &lt;uwagi/&gt;
      [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
      public string POSTCODEMASK {
          get {
              return this.pOSTCODEMASKField;
          }
          set {
              this.pOSTCODEMASKField = value;
          }
      }
  
      /// &lt;uwagi/&gt;
      [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
      public string TOWNGROUP {
          get {
              return this.tOWNGROUPField;
          }
          set {
              this.tOWNGROUPField = value;
          }
      }
  
      /// &lt;uwagi/&gt;
      [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
      public string SERVICE {
          get {
              return this.sERVICEField;
          }
          set {
              this.sERVICEField = value;
          }
      }
  
      /// &lt;uwagi/&gt;
      [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
      public string OPTION {
          get {
              return this.oPTIONField;
          }
          set {
              this.oPTIONField = value;
          }
      }
  }
  
  /// &lt;uwagi/&gt;
  [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.1055.0")]
  [System.SerializableAttribute()]
  [System.Diagnostics.DebuggerStepThroughAttribute()]
  [System.ComponentModel.DesignerCategoryAttribute("code")]
  [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
  public partial class documentERROR {
  
      private string cODEField;
  
      private string dESCRIPTIONField;
  
      /// &lt;uwagi/&gt;
      [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
      public string CODE {
          get {
              return this.cODEField;
          }
          set {
              this.cODEField = value;
          }
      }
  
      /// &lt;uwagi/&gt;
      [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
      public string DESCRIPTION {
          get {
              return this.dESCRIPTIONField;
          }
          set {
              this.dESCRIPTIONField = value;
          }
      }
  }
  
  /// &lt;uwagi/&gt;
  [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.1055.0")]
  [System.SerializableAttribute()]
  [System.Diagnostics.DebuggerStepThroughAttribute()]
  [System.ComponentModel.DesignerCategoryAttribute("code")]
  [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
  public partial class documentPRICE {
  
      private string rATEIDField;
  
      private string sERVICEField;
  
      private string sERVICEDESCField;
  
      private string oPTIONField;
  
      private string oPTIONDESCField;
  
      private string cURRENCYField;
  
      private string rATEField;
  
      private string rESULTField;
  
      /// &lt;uwagi/&gt;
      [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
      public string RATEID {
          get {
              return this.rATEIDField;
          }
          set {
              this.rATEIDField = value;
          }
      }
  
      /// &lt;uwagi/&gt;
      [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
      public string SERVICE {
          get {
              return this.sERVICEField;
          }
          set {
              this.sERVICEField = value;
          }
      }
  
      /// &lt;uwagi/&gt;
      [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
      public string SERVICEDESC {
          get {
              return this.sERVICEDESCField;
          }
          set {
              this.sERVICEDESCField = value;
          }
      }
  
      /// &lt;uwagi/&gt;
      [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
      public string OPTION {
          get {
              return this.oPTIONField;
          }
          set {
              this.oPTIONField = value;
          }
      }
  
      /// &lt;uwagi/&gt;
      [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
      public string OPTIONDESC {
          get {
              return this.oPTIONDESCField;
          }
          set {
              this.oPTIONDESCField = value;
          }
      }
  
      /// &lt;uwagi/&gt;
      [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
      public string CURRENCY {
          get {
              return this.cURRENCYField;
          }
          set {
              this.cURRENCYField = value;
          }
      }
  
      /// &lt;uwagi/&gt;
      [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
      public string RATE {
          get {
              return this.rATEField;
          }
          set {
              this.rATEField = value;
          }
      }
  
      /// &lt;uwagi/&gt;
      [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
      public string RESULT {
          get {
              return this.rESULTField;
          }
          set {
              this.rESULTField = value;
          }
      }
  }
  </code></pre>
  
  <p>I'm trying to deserialize <code>priceResponse.xml</code> but It seems like it is stuck. I think there is problem with namespaces and I'm doing deserialization wrong.</p>
  
  <p>Here is xml code:</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;
  &lt;document&gt;
      &lt;DATASETS&gt;
          &lt;COUNTRY&gt;UTD&lt;/COUNTRY&gt;
          &lt;CURRENCY&gt;UTD&lt;/CURRENCY&gt;
          &lt;POSTCODEMASK&gt;UTD&lt;/POSTCODEMASK&gt;
          &lt;TOWNGROUP&gt;UTD&lt;/TOWNGROUP&gt;
          &lt;SERVICE&gt;UTD&lt;/SERVICE&gt;
          &lt;OPTION&gt;UTD&lt;/OPTION&gt;
      &lt;/DATASETS&gt;
      &lt;ERROR&gt;
          &lt;CODE&gt;P13&lt;/CODE&gt;
          &lt;DESCRIPTION&gt;RATEID: 1 - Standard Rates&lt;/DESCRIPTION&gt;
      &lt;/ERROR&gt;
      &lt;PRICE&gt;
          &lt;RATEID&gt;1&lt;/RATEID&gt;
          &lt;SERVICE&gt;09N&lt;/SERVICE&gt;
          &lt;SERVICEDESC&gt;9:00 Express&lt;/SERVICEDESC&gt;
          &lt;OPTION&gt;NONE&lt;/OPTION&gt;
          &lt;OPTIONDESC&gt;NONE&lt;/OPTIONDESC&gt;
          &lt;CURRENCY&gt;PLN&lt;/CURRENCY&gt;
          &lt;RATE&gt;712.93&lt;/RATE&gt;
          &lt;RESULT&gt;Y&lt;/RESULT&gt;
      &lt;/PRICE&gt;
      &lt;PRICE&gt;
          &lt;RATEID&gt;1&lt;/RATEID&gt;
          &lt;SERVICE&gt;10N&lt;/SERVICE&gt;
          &lt;SERVICEDESC&gt;10:00 Express&lt;/SERVICEDESC&gt;
          &lt;OPTION&gt;NONE&lt;/OPTION&gt;
          &lt;OPTIONDESC&gt;NONE&lt;/OPTIONDESC&gt;
          &lt;CURRENCY&gt;PLN&lt;/CURRENCY&gt;
          &lt;RATE&gt;706.14&lt;/RATE&gt;
          &lt;RESULT&gt;Y&lt;/RESULT&gt;
      &lt;/PRICE&gt;
      &lt;PRICE&gt;
          &lt;RATEID&gt;1&lt;/RATEID&gt;
          &lt;SERVICE&gt;12N&lt;/SERVICE&gt;
          &lt;SERVICEDESC&gt;12:00 Express&lt;/SERVICEDESC&gt;
          &lt;OPTION&gt;NONE&lt;/OPTION&gt;
          &lt;OPTIONDESC&gt;NONE&lt;/OPTIONDESC&gt;
          &lt;CURRENCY&gt;PLN&lt;/CURRENCY&gt;
          &lt;RATE&gt;689.84&lt;/RATE&gt;
          &lt;RESULT&gt;Y&lt;/RESULT&gt;
      &lt;/PRICE&gt;
      &lt;PRICE&gt;
          &lt;RATEID&gt;1&lt;/RATEID&gt;
          &lt;SERVICE&gt;15N&lt;/SERVICE&gt;
          &lt;SERVICEDESC&gt;Express&lt;/SERVICEDESC&gt;
          &lt;OPTION&gt;NONE&lt;/OPTION&gt;
          &lt;OPTIONDESC&gt;NONE&lt;/OPTIONDESC&gt;
          &lt;CURRENCY&gt;PLN&lt;/CURRENCY&gt;
          &lt;RATE&gt;670.03&lt;/RATE&gt;
          &lt;RESULT&gt;Y&lt;/RESULT&gt;
      &lt;/PRICE&gt;
  &lt;/document&gt;
  </code></pre>
  
  <p>And finally deserialization code:</p>
  
  <pre><code>File.WriteAllText("priceResponse.xml", x);
  //Console.WriteLine(x);
  
  var ser = new XmlSerializer(typeof(document),new XmlRootAttribute("documentPRICE"));
  using (var reader = XmlReader.Create("priceResponse.xml"))
  {
      var wrapper = (document)ser.Deserialize(reader);
  
      foreach (documentPRICE item in wrapper.Items)
      {
          Console.WriteLine(item.OPTIONDESC);
      }
  }
  </code></pre>
  
  <p>I would like to get each items in <code>PRICE</code> element, but I can't deserialize xml. What am I doing wrong ? </p>