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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:41:03+00:00 2026-05-13T11:41:03+00:00

Got a real headache at this stage on a Friday! I’m trying to add

  • 0

Got a real headache at this stage on a Friday! I’m trying to add a HtmlNode to another using InsertAfter(). I can see the refChild node with id of breadcrumbs when I rpint it to the console but keep getting the following error:

System.ArgumentOutOfRangeException: Node "<div id="breadcrumb"></div>" was not f
ound in the collection
Parameter name: node
   at HtmlAgilityPack.HtmlNodeCollection.get_Item(HtmlNode node)
   at HtmlAgilityPack.HtmlNode.InsertAfter(HtmlNode newChild, HtmlNode refChild)

   at MyHome.Tasks.Tasks.DownloadandStoreContent(KeyValueP
air`2 urlPair, String filePath, HtmlNode HtmlWrapper) in C:\Users\denis\Document
s\Visual Studio 2008\Websites\MyHomeV2\MyHome.Tasks\Tasks.cs:line 81
   at MyHome.Tasks.Tasks.GenerateContent(String scrape
sSwitch, String filePath) in C:\Users\denis\Documents\Visual Studio 2008\Website
s\MyHomeV2\MyHome.Tasks\Tasks.cs:line 27
   at MyHome.Tasks.Program.Main(String[] args) in C:\Users\denis\Documents\Visua
l Studio 2008\Websites\MyHomeV2\MyHome.Tasks\Program.cs:line 87

My code is:

HtmlWrapper.InsertAfter(ContentNode, HtmlWrapper.SelectSingleNode("//div[@id='breadcrumb']"));

And as mentioned I have printed out both HtmlWrapper and HtmlWrapper.SelectSingleNode(“//div[@id=’breadcrumb’]”) to the console and can see the node on the screen. Any ideas on where I’m going wrong here?

Thanks,
Denis

  • 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-13T11:41:03+00:00Added an answer on May 13, 2026 at 11:41 am

    From a very cursory examination of the source, it looks like InsertAfter wants refChild to be a direct child of the node you invoke InsertAfter on. Since you are searching the entire descendant axis (with //) for your div node, it’s possible that the actual node you pass as refChild isn’t a direct child of HtmlWrapper.

    Try pulling HtmlWrapper.SelectSingleNode("//div[@id='breadcrumb']") into a variable, and then invoking InsertAfter on its ParentNode.

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

Sidebar

Related Questions

I've got a problem which seems to be a real nut. I am using
Got this error message while trying to load view: The model item passed into
I've got a real problem (it's not homework, you can check my profile). I
Got a real simple question but can't figure out the solution. Got following code.
this is a real hair-puller. I've got a junction table that I need to
I got this question in an interview. By real world inheritance the interviewer meant
I've got some code to increase/decrease font size. This is giving me a headache
we've got a real confusing problem. We're trying to test an SQL Bulk Load
I've got a couple projects that were built using hookbox to manage real-time message
We have got the client real IP behind the proxy using X-Forwarded-For. But now

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.