1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Help with HTMLAgility Pack

Discussion in 'Visual Basic .NET' started by mixing, Feb 5, 2016.

  1. mixing

    mixing Regular Member

    Joined:
    Jan 18, 2014
    Messages:
    278
    Likes Received:
    33
    Gender:
    Male
    Location:
    USA
    Home Page:
    Hey everyone.. I have a table similar to below

    Code:
    <table class="whois_result">
    <tr class="whois_domain">
       <th>Domain name</th>
       <td colspan="2">
          test.xyz
       </td>
    </tr>
    <tr class="whois_status status_active">
       <th>Status</th>
       <td colspan="2">
          active
       </td>
    </tr>
    <tr class="whois_registrant">
       <th>Registrant</th>
       <td colspan="2">
           XXXXX-XXXXX<br>
           Bla Bla Bla<br>
           Meander 501, Test Test, Test     
           testestest<br>
           [email protected]<br>
       </td>
    </tr>
    </table>
    
    I am trying to go through the entire page and pull details from specific TR classes. for example, I may want 'whois_result' and 'whois_registrant' from above, but not 'whois_status status_active'..All that I am looking to get is the values in between each (<td colspan="2">) areas, preferably without the <br>'s..

    I'm trying to get these details using HTMLAgilityPack, but not having much luck. Below is the code I've been trying and messing with. Any help would be appriciated!

    Code:
    Dim whois_domain = document.DocumentNode.SelectSingleNode("//tr[@class='whois_domain']//td").Attributes("td").Value.ToString
    
     
  2. NullReferenceX

    NullReferenceX Newbie

    Joined:
    Dec 1, 2015
    Messages:
    41
    Likes Received:
    83
    Occupation:
    Programmer
    Location:
    Germany
    First of all td is not an attribute. But i believe that this is the xpath your looking for "//td[@colspan='2']". Of course you can also get a little bit more specific with "//tr[@class='whois_registrant']/td[@colspan='2']".
     
    Last edited: Feb 6, 2016
  3. Dev Warrior

    Dev Warrior Jr. VIP Jr. VIP Premium Member

    Joined:
    Oct 13, 2015
    Messages:
    265
    Likes Received:
    30
    Home Page:
    Does the above solution provided by NullReferenceX resolve your issue or you further need any help to resolve this issue?