title: Cannot deserialize XML object
body: <p>Here is my XML string:</p>
  
  <pre><code> &lt;Surveys&gt;
     &lt;Survey&gt;
        &lt;SurveyID&gt;33&lt;/SurveyID&gt;
        &lt;CulvertID&gt;5&lt;/CulvertID&gt;
        &lt;PRNo&gt;599422&lt;/PRNo&gt;
        &lt;MP&gt;5.243&lt;/MP&gt;
        &lt;RefMiles&gt;1.500&lt;/RefMiles&gt;
        &lt;PtID&gt;ABCGEFGH&lt;/PtID&gt;
        &lt;FWVersion&gt;10&lt;/FWVersion&gt;
        &lt;SurveyDate&gt;2012-08-21&lt;/SurveyDate&gt;
        &lt;FutureComments&gt;a33537e2-6c2a-4bde-ac99-4da82a93c598&lt;/FutureComments&gt;
        &lt;Erosions&gt;
           &lt;Erosion&gt;
              &lt;ID&gt;158&lt;/ID&gt;
              &lt;SurveyID&gt;33&lt;/SurveyID&gt;
              &lt;Location&gt;Test Erosion - 8/21/2012 - 10:16:10 AM&lt;/Location&gt;
           &lt;/Erosion&gt;
           &lt;Erosion&gt;
              &lt;ID&gt;159&lt;/ID&gt;
              &lt;SurveyID&gt;33&lt;/SurveyID&gt;
              &lt;Location&gt;Test Erosion - 8/21/2012 - 10:16:10 AM&lt;/Location&gt;
           &lt;/Erosion&gt;
        &lt;/Erosions&gt;
        &lt;Spans&gt;
           &lt;Span&gt;
              &lt;ID&gt;86&lt;/ID&gt;
              &lt;SurveyID&gt;33&lt;/SurveyID&gt;
              &lt;Material&gt;Test Span - 8/21/2012 - 10:16:10 AM&lt;/Material&gt;
           &lt;/Span&gt;
           &lt;Span&gt;
              &lt;ID&gt;87&lt;/ID&gt;
              &lt;SurveyID&gt;33&lt;/SurveyID&gt;
              &lt;Material&gt;Test Span - 8/21/2012 - 10:16:10 AM&lt;/Material&gt;
           &lt;/Span&gt;
        &lt;/Spans&gt;
     &lt;/Survey&gt;
     &lt;Survey&gt;
        &lt;SurveyID&gt;35&lt;/SurveyID&gt;
        &lt;CulvertID&gt;5&lt;/CulvertID&gt;
        &lt;PRNo&gt;587180&lt;/PRNo&gt;
        &lt;MP&gt;5.243&lt;/MP&gt;
        &lt;RefMiles&gt;1.500&lt;/RefMiles&gt;
        &lt;PtID&gt;ABCGEFGH&lt;/PtID&gt;
        &lt;FWVersion&gt;10&lt;/FWVersion&gt;
        &lt;SurveyDate&gt;2012-08-27&lt;/SurveyDate&gt;
        &lt;FutureComments&gt;7c36fe43-78cb-436e-81cf-f416aa63c8fc&lt;/FutureComments&gt;
        &lt;Erosions&gt;
           &lt;Erosion&gt;
              &lt;ID&gt;160&lt;/ID&gt;
              &lt;SurveyID&gt;35&lt;/SurveyID&gt;
              &lt;Location&gt;Test Erosion - 8/27/2012 - 1:19:04 PM&lt;/Location&gt;
           &lt;/Erosion&gt;
           &lt;Erosion&gt;
              &lt;ID&gt;161&lt;/ID&gt;
              &lt;SurveyID&gt;35&lt;/SurveyID&gt;
              &lt;Location&gt;Test Erosion - 8/27/2012 - 1:19:04 PM&lt;/Location&gt;
           &lt;/Erosion&gt;
        &lt;/Erosions&gt;
        &lt;Spans&gt;
           &lt;Span&gt;
              &lt;ID&gt;88&lt;/ID&gt;
              &lt;SurveyID&gt;35&lt;/SurveyID&gt;
              &lt;Material&gt;Test Span - 8/27/2012 - 1:19:04 PM&lt;/Material&gt;
           &lt;/Span&gt;
           &lt;Span&gt;
              &lt;ID&gt;89&lt;/ID&gt;
              &lt;SurveyID&gt;35&lt;/SurveyID&gt;
              &lt;Material&gt;Test Span - 8/27/2012 - 1:19:04 PM&lt;/Material&gt;
           &lt;/Span&gt;
        &lt;/Spans&gt;
     &lt;/Survey&gt;
  &lt;/Surveys&gt;
  </code></pre>
  
  <p>Here are my classes..</p>
  
  <p>Survey:</p>
  
  <pre><code>namespace DNR.CulvertInventory.SERVICE
  {
      [XmlRoot(Namespace="",
       ElementName = "Survey",
       DataType = "string",
       IsNullable = true)]
      public class Survey: BOBase
      {
          public int SurveyID { get; set; }
          public int CulvertID { get; set; }
          public string County { get; set; }
          public string RoadName { get; set; }
          public int PRNo { get; set; }
          public decimal MP { get; set; }
          public decimal RefMiles { get; set; }
          public string PtID { get; set; }
          public short FWVersion { get; set; }
          public double? Latitude { get; set; }
          public double? Longitude { get; set; }
          public string Waterway { get; set; }
          public string SiteID { get; set; }
          public string Observers { get; set; }
          public DateTime SurveyDate { get; set; }
          public string AdjacentLandowner { get; set; }
          public string LocationComments { get; set; }
          public short? CrossingType { get; set; }
          public string StructureShape { get; set; }
          public string InletStructure { get; set; }
          public string OutletStructure { get; set; }
          public string OutletType { get; set; }
          public string SubstrateInStructure { get; set; }
          public string GeneralCondition { get; set; }
          public short? PluggedPercent { get; set; }
          public string PluggedLocation { get; set; }
          public short? CrushedPercent { get; set; }
          public string CrushedLocation { get; set; }
          public bool? IsRustedThrough { get; set; }
          public string StructureInterior { get; set; }
          public decimal? StructureWaterDepthInlet { get; set; }
          public decimal? StructureWaterDepthOutlet { get; set; }
          public decimal? StructureEmbeddedDepthInlet { get; set; }
          public decimal? StructureEmbeddedDepthOutlet { get; set; }
          public decimal? StructureWaterVelocityInlet { get; set; }
          public decimal? StructureWaterVelocityOutlet { get; set; }
          public decimal? StructureWaterVelocityMeasured { get; set; }
          public string StructureWaterVelocityMeasuredWith { get; set; }
          public bool? IsPerched { get; set; }
          public decimal? PerchHeight { get; set; }
          public string StreamFlow { get; set; }
          public bool? IsScourPoolPresent { get; set; }
          public decimal? ScourPoolLength { get; set; }
          public decimal? ScourPoolWidth { get; set; }
          public decimal? ScourPoolDepth { get; set; }
          public bool? IsUpstreamPondPresent { get; set; }
          public decimal? UpstreamPondLength { get; set; }
          public decimal? UpstreamPondWidth { get; set; }
          public decimal? RiffleWaterDepth { get; set; }
          public decimal? RiffleBankfullWidth { get; set; }
          public decimal? RiffleWettedWidth { get; set; }
          public decimal? RiffleWaterVelocity { get; set; }
          public string RiffleMeasuredWith { get; set; }
          public string RiffleSubstrate { get; set; }
          public string RoadSurface { get; set; }
          public string RoadCondition { get; set; }
          public decimal? RoadWidth { get; set; }
          public string LocationOfLowPoint { get; set; }
          public string RunOffPath { get; set; }
          public decimal? FillDepthUpStream { get; set; }
          public decimal? FillDepthDownStream { get; set; }
          public string SlopeUpStream { get; set; }
          public string SlopeDownStream { get; set; }
          public decimal? ApproachLengthLeft { get; set; }
          public decimal? ApproachLengthRight { get; set; }
          public string ApproachSlopeLeft { get; set; }
          public string ApproachSlopeRight { get; set; }
          public string VegetationDitchLeft { get; set; }
          public string VegetationDitchRight { get; set; }
          public bool? IsErosionPresent { get; set; }
          public bool? IsErosionCorrectable { get; set; }
          public string ErosionExtent { get; set; }
          public string ErosionNotes { get; set; }
          public bool? IsPrioritySite { get; set; }
          public string PriorityReason { get; set; }
          public string PriorityComments { get; set; }
          public bool? FutureVisit { get; set; }
          public string FutureComments { get; set; }
          public bool? NonNativeInvasiveSpecies { get; set; }
          public string SpeciesObserved { get; set; }
          public bool? IsHeadChanged { get; set; }
          public string HeadChangeComments { get; set; }
          public bool? IsBackwatered { get; set; }
          public string BackwaterComments { get; set; }
          public bool? IsOvertopping { get; set; }
          public string OvertoppingComments { get; set; }
          public bool? IsSubstrateEntireLength { get; set; }
          public decimal? CalculatedPassability { get; set; }
          public decimal? DefinedPassability { get; set; }
          public string PassabilityComments { get; set; }
          public byte[] PhotoInlet { get; set; }
          public byte[] PhotoOutlet { get; set; }
          public byte[] PhotoUpstream { get; set; }
          public byte[] PhotoDownstream { get; set; }
          public byte[] PhotoRoadApproachLeft { get; set; }
          public byte[] PhotoRoadApproachRight { get; set; }
          public List&lt;Erosion&gt; Erosions { get; set; }
          public List&lt;Span&gt; Spans { get; set; }
      }
  }
  </code></pre>
  
  <p>Erosion:</p>
  
  <pre><code>namespace DNR.CulvertInventory.SERVICE
  {
      [XmlRoot(Namespace = "",
       ElementName = "Erosion",
       DataType = "string",
       IsNullable = true)]
      public class Erosion : BOBase
      {
          public int ID { get; set; }
          public int SurveyID { get; set; }
          public string Location { get; set; }
          public decimal? Length { get; set; }
          public decimal? Width { get; set; }
          public decimal? Depth { get; set; }
          public bool? IsReachingStream { get; set; }
          public string MaterialEroded { get; set; }
      }
  }
  </code></pre>
  
  <p>Span:</p>
  
  <pre><code>namespace DNR.CulvertInventory.SERVICE
  {
      [XmlRoot(Namespace = "",
       ElementName = "Span",
       DataType = "string",
       IsNullable = true)]
      public class Span
      {
          public int ID { get; set; }
          public int SurveyID { get; set; }
          public short? SpanNumber { get; set; }
          public decimal? Length { get; set; }
          public decimal? Width { get; set; }
          public decimal? Height { get; set; }
          public string Material { get; set; }
      }
  }
  </code></pre>
  
  <p>And here is the method I am using to deserialize the xml:</p>
  
  <pre><code>public static T GetObjectFromXMLString&lt;T&gt;(string xml) where T: new()
          {
              T myObject = new T();
  
              XmlSerializer serializer = new XmlSerializer(myObject.GetType());
  
              StringReader stream = new StringReader(xml); // read xml data
              XmlTextReader reader = new XmlTextReader(stream);  // create reader
  
              object deserialized = serializer.Deserialize(reader);
  
              myObject = (T)deserialized;
  
              return myObject;
          }
  </code></pre>
  
  <p>And here is the code where I call it:</p>
  
  <pre><code>                command.Connection.Open();
                  using (XmlReader reader = command.ExecuteXmlReader())
                  {
                      while (reader.Read())
                      {
                          string s = reader.ReadOuterXml();
                          // do something with s
                          List&lt;T&gt; myList = Helpers.GetObjectFromXMLString&lt;List&lt;T&gt;&gt;(s);
                          BOList = myList;
                      }
                  }
  </code></pre>
  
  <p>When I attempt to execute this, I get the following error:</p>
  
  <pre><code>"&lt;Surveys xmlns=''&gt; was not expected."
  </code></pre>
  
  <p>What am I doing wrong?  I assume it is something with the namespacing, and I have tried changing the namespace to "", removing the namespace attribute completely from the "XmlRoot" attribute, and also completely removing the "XmlRoot" attribute.  But none of that is working.</p>