HtmlAgilityPack get all elements that have an a tag nested


This is using HtmlAgilityPack . I need to get tr tags with a class of body11 that contain an a tag.I need to access with one of the cells in the row but only for the tags that have a link.have not been having much luck enter image description here

   var tablerows = table.SelectNodes("tr[@class='body11']");

       foreach(HtmlNode row in tablerows)
            var cells = row.SelectNodes(".//td");



also having issue with accessing each individual cell. Currently prints out multiple cells at the same time

                          Contract Ended
                                                    Pay Rate:
                                                    Date Created

                          Health Carousel LLC
                                                    Bill Rate:
                                                    Date Filled:

                          Los Angeles
                                                    OT Rate:
                                                    Date Start:


Accepted Answer

The selector tr.body11 > td > a should work for you. This will select any <a> node nested in a <td> nested in a <tr> that has the class "body11".

This will select you nodes. If you need access to the or , you'll need to traverse up the node graph.

Licensed under: CC-BY-SA
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why