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 9254569
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:30:13+00:00 2026-06-18T11:30:13+00:00

I have 2 lists: public List<string> my_link = new List<string>(); public List<string> english_word =

  • 0

I have 2 lists:

public List<string> my_link = new List<string>();
public List<string> english_word = new List<string>();

I am scraping some links from a page and save them onto "my_link";for this I am using these codes like:

HtmlWeb web = new HtmlWeb();
HtmlAgilityPack.HtmlDocument doc = web.Load("http://search.freefind.com/find.html?id=59478474&pid=r&ics=1&query=" + x);
HtmlNodeCollection nodes=doc.DocumentNode.SelectNodes("//font[@class='search-results']//a");

try
{
    foreach (HtmlNode n in nodes)
    {
        link = n.InnerHtml;
        link = link.Trim();
        my_link.Add(link);
    }
}
catch (NullReferenceException )
{
    MessageBox.Show("NO link found ");            
}
       

Then i am scraping some content going on that links which I scrapped and I stored that content of each link on a english_word.Add(q); It can scrape content from all links except the last one.my code is like that

foreach (string ss in my_link)
{
    HtmlWeb web2 = new HtmlWeb();
    HtmlAgilityPack.HtmlDocument doc2 = web2.Load(ss);
    HtmlNodeCollection nodes2 = doc2.DocumentNode.SelectNodes("//table[@id='table1']//tr[position()>1]//td[position()=2]");
    try
    {
        foreach (HtmlNode nn in nodes2)
        {
            q = nn.InnerText;
            q = System.Net.WebUtility.HtmlDecode(q);
            q = q.Trim();
            english_word.Add(q);
        }
    }
    catch (NullReferenceException ex)
    {
        MessageBox.Show("No english word is found ");
    }
}

For last link only it shows "No english word is found "

What am I doing wrong?

  • 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-06-18T11:30:14+00:00Added an answer on June 18, 2026 at 11:30 am

    First, catching a NullReferenceException here is not a very good idea. It’s better to check for null where you’re expecting nulls.

    Second, most probably you get this exception because of HtmlNode.SelectNodes method returns null (not an empty collection of nodes, as you’ve been expected) if no nodes found. See HTML Agility Pack Null Reference, C#/ Html Agility pack error “Value cannot be null. Parameter name: Source.”, and a discussion on CodePlex.

    So, instead of a try .. catch block you could use something like:

    if (nodes2 != null)
    {
        foreach (HtmlNode nn in nodes2)
        {
            q = nn.InnerText;
            q = System.Net.WebUtility.HtmlDecode(q);
            q = q.Trim();
            english_word.Add(q);
        }
    }
    else
    {
        MessageBox.Show("No english word is found ");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have code similar to this: public List<string> Expected = new List<string>(); public int
I have the following method : public List<string> someMethod() { // populate list of
I have the following C# class: public class SomeClass{ public string Name; public List<SomeClass>
Given that I have the following WCF service: class LookUpService { public List<County> GetCounties(string
I have this bit of code, public static List<string> GetSentencesFromWords(List<string> words, string fileContents) {
I have a list of this class: public class Data { public string name
I have a list of parameters like this: public class parameter { public string
I have this simple code public String toString() { **Iterator it = list.iterator();** String
i have the following code: public static void Serialize() { List<string> dirs = FileHelper.GetFilesRecursive(fileDirectoryPath);
I have a class class PCB { public: struct { string type; **linklist list;**//refer

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.