Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7406001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:29:21+00:00 2026-05-29T05:29:21+00:00

I’m using html agility pack to parse several text files that I load. I

  • 0

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:

MessageBox.Show("test");

Additionally, if I include any other code following this method, none of it is triggered.

Does anyone have any suggestions as to my error?

The entire method is included below:

private void ParseOutput()
{
    nodeDupList = new List<string>();
    StreamWriter OurStream;
    OurStream = File.CreateText(dir + @"\CombinedPages.txt");
    OurStream.Close();
    for (int crawl = 1; crawl <= 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 <= 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");
}

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.

The application is a Win Forms Application targeted at .Net Framework 4.

Edit:
Thanks for the help.

I realized after rerunning it through the debugger that it was crashing at times on the loop

    for (int a = 3; a <= 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"); 
        } 
    } 

when the var specContent was null.

There was no exception generated; the method just ended.

As the website is dynamic that I was crawling it rarely returned null but on several instances it had and this happened.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T05:29:21+00:00Added an answer on May 29, 2026 at 5:29 am

    The solution, for anyone who might need this is to check if

    for (int a = 3; a <= 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')]");
        if(specContent !=null) //added this check for null
        {
            foreach (HtmlNode node in specContent)  
            {  
                nodeDupList.Add(node.InnerText + ".d");  
            }
        }  
    }
    

    I also could have used a try{} catch{} block to output the error if needed

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have thousands of HTML files to process using Groovy/Java and I need to
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.