title: Parsing/Deserialize XML data from API into object - There is an error in XML document (1871, 60)
body: <p>I am working with an XML api, which returns the following:</p>
  
  <pre><code>&lt;inventory&gt;
      &lt;product inventoryId="1722474"  externalReference="SM" site="global" total="0" allocated="0" available="0" frozen="0" onOrder="0" lastStockChangeId="505401" lastLineRequirementChangeId="0"/&gt;
      &lt;product inventoryId="1722476"  externalReference="PM" site="global" total="0" allocated="0" available="0" frozen="0" onOrder="0" lastStockChangeId="243256" lastLineRequirementChangeId="0"/&gt;
      .... 1000s of nodes ....
  &lt;/inventory&gt;
  </code></pre>
  
  <p>So, from this returned xml nodes, I am only interested in the following fields/attributes <code>externalReference</code> and <code>available</code>.</p>
  
  <p>Therefore; I created the following class to describe the xml content I am going to deserialize/parse:</p>
  
  <pre><code>[XmlRoot(ElementName = "product")]
  public class StockLevelProduct
  {
      [XmlAttribute(AttributeName = "externalReference")]
      public string ExternalReference { get; set; }
  
      [XmlAttribute(AttributeName = "available")]
      public string Available { get; set; }
  }
  
  [XmlRoot(ElementName = "inventory")]
  public class StockLevelResult
  {
      [XmlElement(ElementName = "product")]
      public List&lt;StockLevelProduct&gt; Product { get; set; }
  }
  </code></pre>
  
  <p>Then I put it all together like this:</p>
  
  <pre><code>// Init
  StockLevelResult stockLevelResult;
  
  // Anticipate errors
  try
  {
      // Generate request url
      string requestUrl = string.Format("{0}/remotewarehouse/inventory.xml?channel={1}",
          apiUrl,
          apiChannel);
  
      // Call api
      string apiResultXmlString = ApiGet(requestUrl);
  
      // Fix api result xml string
      if (!apiResultXmlString.Contains("&lt;?xml"))
          apiResultXmlString = "&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\r\n" + apiResultXmlString;
  
      // Deserialize xml string to object
      stockLevelResult = XmlParser.Parse&lt;StockLevelResult&gt;(apiResultXmlString);
  }
  catch (Exception ex)
  {
      Console.WriteLine("Failed to download stock levels - " + ex.Message);
  }
  </code></pre>
  
  <p><em>Note* the returned xml string from the API server does not contain <code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;</code> so I manually add it. Note sure if <code>XmlParser.Parse</code> requires it.</em></p>
  
  <p>When this code executes; I get the following exception being thrown:</p>
  
  <blockquote>
    <p>There is an error in XML document (1871, 60)</p>
  </blockquote>
  
  <p>Any ideas why this isn't working? Is it an issue with the returned XML string? or the way I am trying to parse/deserialize it?</p>