title: Cannot serialize XML from an API response. System.InvalidOperationException: 'There is an error in XML document (1, 2).'
body: <p>I am currently doing a project related to a formula 1 API but sadly I cannot figure out how to serialize my xml content into an object.</p>
  <p>The XML I am trying to serialize : <a href="https://pastebin.com/nkt9EA1k" rel="nofollow noreferrer">https://pastebin.com/nkt9EA1k</a></p>
  <p>My API request and the attempt to serialize it.</p>
  <pre><code>        client = new HttpClient();
          HttpResponseMessage response = client.GetAsync(&quot;http://ergast.com/api/f1/2022&quot;).Result;
          HttpContent responseContent = response.Content;
          XmlSerializer serializer = new XmlSerializer(typeof(Wrapper));
          Wrapper wrapper2;
          string result = File.ReadAllText(&quot;temp.txt&quot;);//hc.ReadAsStringAsync().Result;
          using (TextReader reader = new StringReader(result))
          {
              wrapper2 = (Wrapper)serializer.Deserialize(reader);
          }
          if(wrapper2 != null)
          {
              SecondWrapper wrapper = wrapper2.MRData;
              string outPut = wrapper.Season;
              foreach (Race r in wrapper.RaceTable)
              {
                  outPut += $&quot;\n{r.RaceName}\t{r.Date}\t{r.Circuit.CircuitName}&quot;;
              }
              File.WriteAllText(&quot;Output.txt&quot;, outPut);
          }
  </code></pre>
  <p>My Wrapper class :</p>
  <pre><code>public class Wrapper
  {
      public SecondWrapper MRData;
  }
  </code></pre>
  <p>My SecondWrapper Class :</p>
  <pre><code>public class SecondWrapper
  {
      public string Season;
      public Race[] RaceTable;
  }
  </code></pre>
  <p>My Race class :</p>
  <pre><code>public class Race
  {
      public string RaceName { set; get; }
      public Circuit Circuit { set; get; }
      public string Date;
      public string Time;
      public StepDateTime FirstPractice { set; get; }
      public StepDateTime SecondPractice { set; get; }
      public StepDateTime ThirdPractice { set; get; }
      public StepDateTime Qualifying { set; get; }
      public StepDateTime Sprint { set; get; }
  }
  </code></pre>
  <p>My Circuit class :</p>
  <pre><code>public class Circuit
  {
      public string CircuitName { set; get; }
      public Location Location { set; get; }
  }
  </code></pre>
  <p>My Location class :</p>
  <pre><code>public class Location
  {
      public double lat { set; get; }
      [XmlAttribute(&quot;long&quot;)]
      public double Long { set; get; }
      public string Locality { set; get; }
      public string Country { set; get; }
  }
  </code></pre>
  <p>My StepDateTime class :</p>
  <pre><code>public class StepDateTime
  {
      public string Date { set; get; }
      public string Time { set; get; }
  }
  </code></pre>
  <p>I tried to make a text file where I deleted the first 2 lines of the XML answer hoping it would fix the issue but it didn't.</p>
  <p>PS : I know I'm not using propreties and I am not respecting the c# conventions for the classes but it is temporary just so I can find a way to fix the issue. It is also my first time working with xml answers so I might have done some obvious errors.</p>
  <p>Thanks for the help.</p>