title: Parsing HTML with LINQ
body: <p>I'm trying to take all cells from a HTML table using Html Agility Pack and LINQ.
  I have loaded the HTML source in a HtmlAgilityPack.HtmlDocument and selected the  tags with LINQ. However after using foreach to iterate the result, it crashes in the second record.</p>
  
  <p>This is a fragment of the HTML source:</p>
  
  <pre><code>&lt;tr&gt;
      &lt;td class='city'&gt;New York&lt;/td&gt;
      &lt;td&gt;Card 1&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
      &lt;td class='city'&gt;London&lt;/td&gt;
      &lt;td&gt;Card 2&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
      &lt;td class='city'&gt;Tokyo&lt;/td&gt;
      &lt;td&gt;Card 3&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
      &lt;td class='city'&gt;Berlin&lt;/td&gt;
      &lt;td&gt;Card 4&lt;/td&gt;
  &lt;/tr&gt;
  </code></pre>
  
  <p>And this is what I made:</p>
  
  <pre><code>htmlDoc.LoadHtml(await msgRecived.Content.ReadAsStringAsync());
  
  var tds=
      from td in htmlDoc.DocumentNode.Descendants("td")
      where td.Attributes["class"].Value == "city"
      select td.InnerText;
  
  foreach (var td in tds)
  {
      citiesText = citiesText + " " + td;
  }
  </code></pre>
  
  <p>It only return the first element, e.g. if instead of using foreach I do:</p>
  
  <pre><code>citiesText = tds.ElementAt(0);
  </code></pre>
  
  <p>It returns <em>New York</em>, but if I try ElementAt(1) it crashes with <em>Object reference not set to an instance of an object.</em></p>
  
  <p>Any help? Thanks</p>