Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9239947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:06:18+00:00 2026-06-18T08:06:18+00:00

looking to get two parents up (great grand parents) or two children down? <table

  • 0

looking to get two parents up (great grand parents) or two children down?

<table style="background-color: #008000; border-style: none;" border="0" cellpadding="2" cellspacing="2">
  <tr>
    <td>
      <img height="5" width="5" border="0" src="https://spacer.gif" title="07:00,24hrs: B Shift /.../E704/RS704/Firefighter #2" alt="07:00,24hrs: B Shift /.../E704/RS704/Firefighter #2">
    </td>
  </tr>
</table>
<img height="2" width="2" border="0" src="https://spacer.gif" alt="">
  <img alt="" height="1" width="1" border="0" src="https://spacer.gif">
    </td>
    <TD ALIGN="RIGHT" VALIGN="TOP" width="17%">
      <a href="javascript:void(0)" title="01/15/2013" class="daylink" onClick="return DayClick('01/15/2013');">15</a>
    </TD>
    <td rowspan="2" width="5">
      <img alt="" height="1" width="1" border="0" src="https://spacer.gif">
    </td>
    </tr>
    <tr>
      <TD COLSPAN="2">
        <TABLE>
          <TR>
            <TD style="background-color: #41FFB9; " class="calexception">
              <a href="javascript:void(0)" onClick="return ShowRemoveExceptionWindow(&quot;4A30E80.fre01&quot;,&quot;3280530&quot;);" title="10hrs DetNonEMSStud(10),  07:00 - 17:00" style="color: #000000; text-decoration: none; font-weight: bold;">DetNonEMSStud(10)</a>
            </TD>
          </TR>
        </TABLE>

iOS:

NSString *tutorialsXpathQueryString = @"//table/tr/td";
NSArray *tutorialsNodes = [tutorialsParser searchWithXPathQuery:tutorialsXpathQueryString];
NSLog(@"here is url: %@", tutorialsNodes);

NSMutableArray *newTutorials = [[NSMutableArray alloc] initWithCapacity:0];
for (TFHppleElement *element in tutorialsNodes) {

    Tutorial *tutorial = [[Tutorial alloc] init];
    [newTutorials addObject:tutorial];

    tutorial.url = [element objectForKey:@"style"];
    tutorial.title = [[element firstChild] objectForKey:@"title"];

I’m getting style from <td> and title from <a> just fine
I also need to get the style from <table>

I’m very new to obj-c and first attempt with XPATH, any sample would be great!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T08:06:19+00:00Added an answer on June 18, 2026 at 8:06 am

    I have not used TFHpple, but if it supports standard XPath, you should be able to go from a td to its containing table with this XPath:

    ancestor::table[1]
    

    This XPath selects the nearest table that is an ancestor of the context node, so if you had this markup:

    <table>
        <tr><td></td></tr>
        <tr>
           <td>
             <table><tr><td></td></tr></table>
             <table>
                 <tr>
                     <td>Hey!</td>
                 </tr>
             </table>
           </td>
        </tr>      
    </table>
    

    And your context node was the td with the text “Hey!”, then the above XPath would select the table on line 6.

    It looks like TFHpple doesn’t provide a way to evaluate XPath on a context node. Given that, a new suggestion – every element only has one parent, so if you keep going up through the parents, you should eventually find the table. It’s a lot harder to go downward because an element could have any number of direct children, each with their own sets of children. I don’t really know Objective-C, but if you can be sure that the table is only two levels up, then something like this would probably work:

    TFHppleElement *table = [[element parent] parent];
    

    If there’s no guarantee that the table is two levels up, then there should be some way to find the table by going up through the parents. This is pseudocode, but hopefully you get the idea:

    for (TFHppleElement *element in tutorialsNodes) {
    
        Tutorial *tutorial = [[Tutorial alloc] init];
        [newTutorials addObject:tutorial];
    
        tutorial.url = [element objectForKey:@"style"];
        tutorial.title = [[element firstChild] objectForKey:@"title"];
    
        TFHppleElement *table = [element parent];
        while(table != null && [table tagName] != "table") {
            table = [table parent]
        }
    
        // table should either be the parent table at this point, 
        //  or null if there was no parent table.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I’m looking to get the max discrepancy between two tables per day, per id.
I am looking to get 4 buttons on the screen. Two on top and
When looking to get data from a web page whats the recommended method if
I'm looking to get a Regex for the following password strength requirements: Minimum 8
I'm looking to get an instance of Solr search running on my localhost. The
I'm looking to get up to speed on Python : Is it worth working
I am looking to get into operating system kernel development and figured my contribution
I am looking to get into operating system kernel development and figured and have
I am looking to get access to all HTTP traffic on my machine (my
We am looking to get a list of bugs per user story in TFS

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.