2

I have a problem with "Hpple". I'm parse html file, and I want to get the entire table, but the result I get (null).

My code in Objective-C:

-(void)loadTutorials {

    // 1

    paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    filePath = [NSString stringWithFormat:@"%@/%@", [paths objectAtIndex:0],@"index.html"];

    NSData  *data = [NSData dataWithContentsOfFile:filePath];

    // 2
    TFHpple * doc   = [[TFHpple alloc] initWithHTMLData:data];

    // 3
    NSString *tutorialsXpathQueryString = @"/html/body/div/table/tr/td[@class='bottomwideborder']"; //Next comes the big table

    NSArray *tutorialsNodes = [doc searchWithXPathQuery:tutorialsXpathQueryString];


    for (TFHppleElement *element in tutorialsNodes) {

        table = [element text];

    }

}

- (void)viewDidLoad
{
    [super viewDidLoad];

    [self loadTutorials];

    html = [NSString stringWithFormat:@"<html><body>%@</body></html>", table];

    [Web loadHTMLString:html baseURL:nil];

}

Table that I want to parse too get is a long and I think that it's too big for NSString or NSArray

What can I do to fix this?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
IlyaKharlamov
  • 479
  • 1
  • 4
  • 10
  • Where is ivar table initialized, what type of object is it ? If its an array and you are trying to hold [element text] in table array then you are not adding element text. – 0x8badf00d Nov 09 '12 at 18:31

0 Answers0