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 9206043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:05:33+00:00 2026-06-18T00:05:33+00:00

How can I get elements further down the array than firstChild or parent NSString

  • 0

How can I get elements further down the array than firstChild or parent

NSString *tutorialsXpathQueryString = @"//table/tr/td/ancestor::table[1]";
//  @"//tr/td/table/tr/td/a"

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

NSMutableArray *newTutorials = [[NSMutableArray alloc] initWithCapacity:0];
for (TFHppleElement *element in tutorialsNodes) {
    // 5
    Tutorial *tutorial = [[Tutorial alloc] init];
    [newTutorials addObject:tutorial];

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

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

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

    //tutorial.url = [element tagName];


    tutorial.title = [[element parent] objectForKey:@"title"];

    //tutorial.title = [element objectForKey:@"title"];

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

    //tutorial.title = [[element firstChild] tagName];

sample of my array:

{\n                   nodeAttributeArray =                                                          (\n         {\n           attributeName = style;\n                                                             nodeContent = \"background-color: #008000; border-style: none;\";\n                                                          },\n                                                                                                                 {\n                                                            attributeName = border;\n                                                              nodeContent = 0;\n                                                        },\n                                                                                                                  {\n                                                            attributeName = cellpadding;\n                                                              nodeContent = 2;\n                                                        },\n                                                                                                                  {\n                                                            attributeName = cellspacing;\n                                                              nodeContent = 2;\n                                                        }\n                                                      );\n                                                    nodeChildArray =                                                       (\n                                                                                                                   {\n                                                            nodeChildArray =                                                              (\n                                                                                                                                 {\n                                                                    nodeChildArray =                                                                      (\n            },\n                                                                                                                                                                {\n                                                                                    attributeName = border;\n                                                                                    nodeContent = 0;\n                                                                                },\n                                                                                                                                                                {\n                                                                                    attributeName = src;\n                                                                                    nodeContent = \"https://spacer.gif\";\n                                                                                },\n                                                                                                                                                                {\n                                                                                    attributeName = title;\n                                                                                    nodeContent = \"07:00,24hrs: B Shift /.../E704/RS704/Firefighter #2\";\n                                                                                },\n                                                                                                                                                                {\n                                                                                    attributeName = alt;\n                                                                                    nodeContent = \"07:00,24hrs: B Shift /.../E704/RS704/Firefighter #2\";\n                                                                                }\n                                                                            );\n                                                                            nodeName = img;\n                                                                        }\n                                                                    );\n                                                                    nodeName = td;\n                                                                },\n                                                                                                                                
  • 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-18T00:05:34+00:00Added an answer on June 18, 2026 at 12:05 am

    I’m not experienced with Objective-C, but please give this a try.

    The TFHppleElement’s parent property is itself a TFHppleElement, so it in turn has a parent. If you keep going up through these parents, you should eventually find the node you’re looking for. For example to get a parent 2 levels up:

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

    Since your XPath will only locate tds that are two levels under a table (and indeed, that’s the only place they should be), then retrieving the parent’s parent should get you the table you’re looking for.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

how can i get elements uniquely from an array
How can I get all td elements with 'colspan' greater than 1 in jQuery?
How can I get the input elements form a certain div inside a form
How can I get all tr elements without id attribute? <tr id=name>...</tr> <tr>...</tr> <tr>...</tr>
How can I get the text value from an elements's child? Say I have
Using jQuery I can easily get the number of DOM elements used by a
How can I ignore first element and get rest of the elements? <ul> <li><a
I remember seen some code xaml where can get the first element (like an
How can I get fontSize of element in px or pt ? Or can
Using jQuery, how can I get the input element that has the caret's (cursor's)

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.