© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
44 replies
malkav

❔ ✅ Scrape all <table> </table> elements

I'm trying to use AngleSharp to scrape any url (that is given as parameter) for all table elements on that page's HTML code, and parse the contents into a json.

Here's an example of what I'm trying to achieve:

<table>
  <thead>
    <tr>
      <th scope="col">Header 1</th>
      <th scope="col">Header 2</th>
      <!-- etc -->
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>1</th>
      <td>data</td>
      <!-- etc -->
    </tr>
    <!-- etc -->
  </tbody>
</table>
<table>
  <thead>
    <tr>
      <th scope="col">Header 1</th>
      <th scope="col">Header 2</th>
      <!-- etc -->
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>1</th>
      <td>data</td>
      <!-- etc -->
    </tr>
    <!-- etc -->
  </tbody>
</table>


the json output:
[
  {
    "Header 1": "1",
    "Header 2": "data",
    // etc
  },
  // etc
]
[
  {
    "Header 1": "1",
    "Header 2": "data",
    // etc
  },
  // etc
]

The code I'm trying so far seems to make it hard to reach this actual element, even when trying to use
QuerySelectorAll("table")
QuerySelectorAll("table")
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

List not returning all matching elements
C#CC# / help
2y ago
✅ JsonConvert.DeserializeObject return contains all null elements
C#CC# / help
3y ago
❔ Scrape with HtmlAgilityPack
C#CC# / help
3y ago