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

  • Home
  • SEARCH
  • 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 6715619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:38:09+00:00 2026-05-26T08:38:09+00:00

With using c# 4.0 and htmlagilitypack how can i read values inside certain table.

  • 0

With using c# 4.0 and htmlagilitypack how can i read values inside certain table. I mean lets say there are 10 tables and i want to read values from 6 th or i have table id.

Or lets say i want to read td value coming after certain td.

Or table coming after certain div or element or text. Are these possible ?

  • 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-26T08:38:10+00:00Added an answer on May 26, 2026 at 8:38 am

    Everything you have asked about could be done relatively easily. It doesn’t matter that its documentation might be lacking, it should be similar to XML and the network’s XmlDocument implementation in both use and functionality.

    How can I read values inside certain table? Let’s say there are 10 tables and I want to read values from 6th or I have table id.

    Finding the 6th table:

    // XPath
    var table6 = doc.DocumentNode.SelectSingleNode("//table[6]");
    
    // LINQ
    var table6 = doc.DocumentNode.Descendants("table").Skip(5).FirstOrDefault();
    

    Finding the table/element by id:

    var myTable = doc.GetElementById("myTable");
    
    // XPath
    var myTable = doc.DocumentNode.SelectSingleNode("//table[@id='myTable']");
    var myTable = doc.DocumentNode.SelectSingleNode("//*[@id='myTable']");
    
    // LINQ
    var myTable = doc.DocumentNode
        .Descendants("table")
        .Where(table => table.Attributes.Contains("id"))
        .SingleOrDefault(table => table.Attributes["id"].Value == "myTable");
    var myTable = doc.DocumentNode
        .Descendants()
        .Where(e => e.Attributes.Contains("id"))
        .SingleOrDefault(e => e.Attributes["id"].Value == "myTable");
    var myTable = doc.DocumentNode
        .Descendants("table")
        .SingleOrDefault(table => table.GetAttributeValue("id", null) == "myTable");
    var myTable = doc.DocumentNode
        .Descendants()
        .SingleOrDefault(e => e.GetAttributeValue("id", null) == "myTable");
    

    Let’s say I want to read td value coming after certain td.

    // XPath
    var certainTd = table6.SelectSingleNode("//td[2]");
    var tdAfterCertainTd = certainTd.SelectSingleNode("following-sibling::td[1]");
    
    // LINQ (not so easy)
    var certainTd = table6.Descendants("td").Skip(1).FirstOrDefault();
    var tdAfterCertainTd = certainTd.NextSibling;
    while (tdAfterCertainTd != null)
    {
        if (tdAfterCertainTd.Name == "td")
            break;
        tdAfterCertainTd = tdAfterCertainTd.NextSibling;
    }
    

    Table coming after certain div or element or text.

    // XPath
    var certainDiv = doc.DocumentNode.SelectSingleNode("//div[1]");
    var tableAfterCertainDiv = certainDiv.SelectSingleNode("following-sibling::table[1]");
    
    // LINQ (not so easy)
    var certainDiv = doc.DocumentNode.Descendants("div").FirstOrDefault();
    var tableAfterCertainDiv = certainDiv.NextSibling;
    while (tableAfterCertainDiv != null)
    {
        if (tableAfterCertainDiv.Name == "table")
            break;
        tableAfterCertainDiv = tableAfterCertainDiv.NextSibling;
    }
    

    You should notice some patterns.

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

Sidebar

Related Questions

I am using HtmlAgilityPack. Is there a one line code that I can get
I'm using HtmlAgilityPack and I'd like to select the value from inside the td
I've been using the HtmlAgilityPack to eat some XHTML documents, however, if I want
Im using HtmlAgilityPack/HAP so that I can use Xpath with HTML documents. I need
I am using C# with HtmlAgilityPack and I can select divs that have an
Can I put OR clause in node selection using HTMLAgility (HtmlAgilityPack.HtmlNodeCollection)doc.DocumentNode.SelectNodes(//td[@class=\roomPrice figure\]); What I
I am using HtmlAgilityPack to read a parse a html file and extract some
I'm using HtmlAgilityPack to parse HTML. I want to check if an element has
With using HtmlAgilityPack and c# 4.0 how can you determine whether page is being
I have been using HTMLAgilityPack from within Visual Studio without a single problem. I

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.