0

I have the following table:

<table id="history-table" width="100%" cellpadding="0" cellspacing="0" border="0" class="listTable">
        <thead style="font-weight: bold; background-color: #eee;">
            <tr>
                <td style="padding-left: 10px; padding-right: 10px;">Date
                </td>
                <td style="padding-left: 10px; padding-right: 10px;">Description
                </td>
                <td style="padding-left: 10px; padding-right: 10px; text-align: right;">Amount
                </td>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td></td>
                <td></td>
                <td></td>
            </tr>
            <tr>
                <td></td>
                <td></td>
                <td></td>
            </tr>
            <tr>
                <td></td>
                <td></td>
                <td></td>
            </tr>
        </tbody>
 </table>

I want to select all cells in the tbody element using HtmlAgilityPack, but so far I am not able to do it.
Here is what I tried:

var table = doc.DocumentNode.SelectNodes("//*[@id='history-table']/tbody/tr"); - returns null

var table = doc.DocumentNode.SelectNodes("//*[@id='history-table']//tr"); - returns only the thead rows

var billNumbers = doc.DocumentNode
                                .Descendants("table")
                                .Where(table => table.Attributes.Contains("id"))
                                .SingleOrDefault(table => table.Attributes["id"].Value == "history-table"); - then trying couple of ways to foreach the result, still no success

When I copy the XPath from Chrome and paste it in the SelectNodes it returns null. Any ideas will be greatly appreciated

zav
  • 55
  • 1
  • 8
  • So, just to be clear, when you `View Source` in your browser (and do exactly that - don't use Developer Tools) you get the above HTML? **Do not guess**. – mjwills Aug 17 '21 at 07:02
  • @mjwills no, when I open the View Source the element is empty and its populated by javascript function when the page loads..... – zav Aug 17 '21 at 07:07
  • 1
    Give https://html-agility-pack.net/from-browser a read. – mjwills Aug 17 '21 at 07:09

0 Answers0