Obj-C can't parse HTML

82 Views Asked by At

I am parsing some HTML, and I keep getting that the node is nil, when I know its not and I have evaluated the same xPath string in both Safari and Chrome and it takes me where I want here is the code.

In viewDidLoad

self.url = @"https://rpi.sodexomyway.com/dining-choices/res/index.html";
[self getMenuItems:self.url];

In getMenuItems:

//I just get the data aSync
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:url]];
[NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {

    [self getData:data];

}];

In getData:

TFHpple *Parser = [TFHpple hppleWithHTMLData:factData];

NSString *planString = @"/html[@class='cufon-active cufon-ready']/body/div[@id='main-content']/div[@id='subs-container']/div[@class='main-corners']/div[@class='column-66 float-left']/div[@class='pane-accord']/div[@id='hideinse']/div[@id='accordion_23471']/div[@id='ui-accordion-accordion_23471-panel-1']/span/p[3]";
NSArray *tutorialsNodes = [Parser searchWithXPathQuery:planString];

NSLog(@"tut: %@", tutorialsNodes);

for (TFHppleElement *element in tutorialsNodes) {

    NSLog(@"element: %@", [element text]);

}

But tutorialsNodes comes back as an empty array and Im not sure why, you can go to the site in this question and put that xPath in the console and you get this text Tuesday: 7:30a - 7:30p . But it is not being returned where is my code going wrong?

Why is the array nil?

Thanks for the help in advance.

0

There are 0 best solutions below