HtmlAgilityPack get all elements that have an a tag nested

c# css-selectors html-agility-pack

Question

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");

            Console.WriteLine(cells[0].InnerText);


        }

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

                          SReason:
                          Contract Ended
                                                    Pay Rate:
                          $73.58
                                                    Date Created
                                                            :
                                                        09/05/2017



                          Sup:
                          Health Carousel LLC
                                                    Bill Rate:
                          $73.58
                                                    Date Filled:
                          09/07/2017


                          City:
                          Los Angeles
                                                    OT Rate:
                          $110.37
                                                    Date Start:

                              09/03/2017
1
0
1/30/2018 7:03:12 PM

Accepted Answer

The choosertr.body11 > td > a must function for you. This will decide which<a> nested node in a<td> enclosed in a<tr> It is of the "body11" class.

This will choose your nodes for you. You must go up the node network if you require access to the or.

1
1/30/2018 6:28:27 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow