Note that there are some explanatory texts on larger screens.

plurals
  1. POMethod Hangs on for loop and won't continue
    text
    copied!<p>I'm using html agility pack to parse several text files that I load. I then save the data that I parse out into a string list for further processing. However, when I use this method, it never hits the line:</p> <pre><code>MessageBox.Show("test"); </code></pre> <p>Additionally, if I include any other code following this method, none of it is triggered.</p> <p>Does anyone have any suggestions as to my error?</p> <p>The entire method is included below:</p> <pre class="lang-cs prettyprint-override"><code>private void ParseOutput() { nodeDupList = new List&lt;string&gt;(); StreamWriter OurStream; OurStream = File.CreateText(dir + @"\CombinedPages.txt"); OurStream.Close(); for (int crawl = 1; crawl &lt;= crawlPages.Length; crawl++) { var web = new HtmlWeb(); var doc = web.Load(dir + @"\Pages" + crawl.ToString() + ".txt"); var nodeCount = doc.DocumentNode.SelectNodes(@"/html[1]/body[1]/div[1]/table[3]/tbody[1]/tr[td/@class=""style_23""]"); int nCount = nodeCount.Count; for (int a = 3; a &lt;= nCount; a++) { var specContent = doc.DocumentNode.SelectNodes(@"/html[1]/body[1]/div[1]/table[3]/tbody[1]/tr[" + a + @"]/td[3]/div[contains(@class,'style_24')]"); foreach (HtmlNode node in specContent) { nodeDupList.Add(node.InnerText + ".d"); } } } MessageBox.Show("test"); } </code></pre> <p>I've created a crawler to save multiple html pages to text and parse them separately using this method. I'm just using MessageBox to show that it won't continue following the "for loop". I've called multiple methods in my solution and it won't iterate through them.</p> <p>The application is a Win Forms Application targeted at .Net Framework 4.</p> <p><strong>Edit:</strong> Thanks for the help.</p> <p>I realized after rerunning it through the debugger that it was crashing at times on the loop </p> <pre><code> for (int a = 3; a &lt;= nCount; a++) { var specContent = doc.DocumentNode.SelectNodes(@"/html[1]/body[1]/div[1]/table[3]/tbody[1]/tr[" + a + @"]/td[3]/div[contains(@class,'style_24')]"); foreach (HtmlNode node in specContent) { nodeDupList.Add(node.InnerText + ".d"); } } </code></pre> <p>when the var specContent was null.</p> <p>There was no exception generated; the method just ended.</p> <p>As the website is dynamic that I was crawling it rarely returned null but on several instances it had and this happened.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload