0

I'm currently using CsQuery which is similar to HtmlAgilityPack, it allows you manipulate a virtual dom as .net objects. I'm currently trying to iterate through a html table so that I can build a datatable from it, however the cells are mixed whether they're nested in divs or anchor tags so it's not always the same selector. Is there a css selector I can use that will find the lowest level child element?

Here's an example of a table I am trying to select from.

<table>
    <tr>
        <th>TestCol1</th>
        <th>TestCol2</th>
        <th>TestCol3</th>
    </tr>
    <tr>
        <td><div><a>41</a></div></td>
        <td><div>Testttttt</div></td>
        <td>Testestst</td>
    </tr>
</table>

If I was to use the selectr 'tr td div a', I miss row 2 and 3. At the moment I am having to use if statements to try all three selector variations. In an ideal row I would use the selector and it would extract the inner text for every td.

If anything didn't make sense, please let me know and I will reiterate.

Jacob Mason
  • 1,355
  • 5
  • 14
  • 28
  • This might help you get started http://stackoverflow.com/questions/3787924/select-deepest-child-in-jquery – Pugazh Apr 05 '16 at 10:15

1 Answers1

1

How do I select the innermost element?

Basicaly you have to select all elements which do not have any childen.

Community
  • 1
  • 1
IdeaMan
  • 717
  • 4
  • 13