title: Getting a loop to build a string correctly
body: <p>I'm trying to pull the tournament age from this webpage:</p>
  
  <p><a href="http://www.reddishvulcans.com/uk_tournament_database.asp" rel="nofollow">http://www.reddishvulcans.com/uk_tournament_database.asp</a></p>
  
  <p>I'm trying to create a string based on the valid ages for entry for each table.</p>
  
  <p>For example, if the "Carling Cup" is enterable by 7 year olds, then a string would be generated like "U7", or if it's enterable by 7, 8, and 9 year olds, the resulting string will be "U7, U8, U9".</p>
  
  <p>I've made a start, however my logic will break if the ages go like this "Under 7s, <strong>Gap here where no under 8s</strong>, Under 9s".</p>
  
  <p>Here is my code:</p>
  
  <pre><code>public static List&lt;Record&gt; getRecords()
      {
          string url = "http://www.reddishvulcans.com/uk_tournament_database.asp";
          var Webget = new HtmlWeb();
          var doc = Webget.Load(url);
          var root = doc.DocumentNode;
          var ages = root.SelectNodes("//div[@class='infobox']/table/tr[5]/td/img");
  
          List&lt;String&gt; tournamentAges = new List&lt;String&gt;();
          String ageGroups = "";
          List&lt;String&gt; ageString = new List&lt;String&gt;();
  
          for (Int32 i = 0; i &lt; ages.Count(); i++)
          {
  
              if (ages[i].GetAttributeValue("src", "nope") == "images/2016/u6_Yes.gif")
              {
                  if (!ageString.Contains(" U6 ")) {
                      ageString.Add(" U6 ");
                      continue;
                  }
              }
              else if (ages[i].GetAttributeValue("src", "nope") == "images/2016/u6_.gif")
              {
                  continue;
              }
  
              if (ages[i].GetAttributeValue("src", "nope") == "images/2016/u7_Yes.gif")
              {
                  if (!ageString.Contains(" U7 "))
                  {
                      ageString.Add(" U7 ");
                      continue;
                  }
              }
              else if (ages[i].GetAttributeValue("src", "nope") == "images/2016/u7_.gif")
              {
                  continue;
              }
  
              if (ages[i].GetAttributeValue("src", "nope") == "images/2016/u8_Yes.gif")
              {
                  if (!ageString.Contains(" U8 "))
                  {
                      ageString.Add(" U8 ");
                      continue;
                  }                
              }
              else if (ages[i].GetAttributeValue("src", "nope") == "images/2016/u8_.gif")
              {
                  continue;
              }
               // Checks until u16.gif
  
              foreach (String a in ageString)
              {
                  if (a != "")
                  {
                      ageGroups += a;
                  }
  
              }
  
              ageString.Clear();
              if (ageGroups != "")
                    {
                  tournamentAges.Add(ageGroups);
              }
              ageGroups = "";
              }
          }
  }
  </code></pre>
  
  <p>To be clear, I'm having trouble with the loop logic.</p>
  
  <p>The flow currently goes like this:</p>
  
  <pre><code>Loop through current list of images
      If &gt; u6_Yes.gif 
          Concatenate u6 to ageString
      else
          Continue
  </code></pre>
  
  <p>However it will continue back to the start and get stuck in an infinite loop, How can I make it gracefully handle when u6_.gif is gone, ignore it and go to the next?</p>