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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:18:40+00:00 2026-06-15T04:18:40+00:00

the Code: NSString *linkStr=@http://www.voanews.com/content/obama_pledges_aid_to_drought_stricken_farmers/1484380.html; NSData *data = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:linkStr]]; // Create parser

  • 0

the Code:

NSString *linkStr=@"http://www.voanews.com/content/obama_pledges_aid_to_drought_stricken_farmers/1484380.html";
NSData *data = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:linkStr]];

// Create parser  
TFHpple *xpathParser = [[TFHpple alloc] initWithHTMLData:data];  

//Get all the cells of the 2nd row of the 3rd table   
NSArray *elements  = [xpathParser searchWithXPathQuery:@"//p[@class='article_date']"];  

// Access the first cell  
if ([elements count] > 0) 
{
    TFHppleElement *element = [elements objectAtIndex:0];  

    // Get the text within the cell tag  
    NSString *content = [element content];    
    NSLog(@"VOA = %@",content);       //Result : print NULL
}


[xpathParser release];  
[data release]; 

but I use the XPath Helper query the “//p[@class=’article_date’]” ,it’s ok, but in my code the content is null

  • 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-15T04:18:41+00:00Added an answer on June 15, 2026 at 4:18 am

    Running your code example, if I change [element content] for [element text], my output is:

    VOA = August 11, 2012

    In its Github repo, they mention (at USAGE section):

    [e text]; // The text inside the HTML element (the content of the
    first text node)

    And looking at the source code of the CONTENT method it uses objectForKey, where TFHppleContentKey = "nodeContent". See:

    static NSString * const TFHppleNodeContentKey = @"nodeContent"
    
    // Returns this tag's innerHTML content.
    - (NSString *) content
    {
        return [node objectForKey:TFHppleNodeContentKey];
    }
    

    It seems that it’s safe to use [element text] instead of [element content] in your example.

    I hope it helps.

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

Sidebar

Related Questions

I have the following Objective-C code: NSString *urlStr=[[NSString alloc] initWithFormat:@http://www.prestocab.com/driver/ajax/getFriendsOnMap.php]; NSURL *url=[NSURL URLWithString:urlStr]; __block
I currently have this piece of code: NSString *strURL = [NSString stringWithFormat:@http://www.sample.com /phpFile.php?firstname=%@,txtfirstName.text]; NSString
I'm using this code: NSString *recievedData; NSURLRequest *theRequest=[NSURLRequest requestWithURL:[NSURL URLWithString:@http://www.site.com/] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0]; // create
I have this code NSString *tr = [self sendUrl:@http://google.com/]; But for some reason '
I have the following code: NSString *text = @http://bit.ly/111 http://bit.ly/222 http://www.www.www; NSRegularExpression *aLinkRegex =
I have the following code: NSString *indexText = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; if (indexText==nil)
I have this piece of code: NSString *body = dataItem.body; NSData* data=[body dataUsingEncoding:NSUTF8StringEncoding]; if
Please consider this code: NSString *jsonreturn = [[NSString alloc] initWithContentsOfURL:[ NSURL URLWithString:url ]]; //
Here Below is my code NSString *string = [NSString stringWithFormat:@ http://abc.com /Demo/View.php?drinkId=%@&name=%@&comment=%@&date=%@&rating=%@& ReqestType=SubmitComment,DrinkId,Name,Comment,Date,Rating]; NSURL
Here is my code : NSString *path1 = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@NewSouthWales.html]; NSURL *pageURL

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.