ios - Obj-C can't parse HTML -
i parsing html, , keep getting node nil, when know not , have evaluated same xpath string in both safari , chrome , takes me want here code.
in viewdidload
self.url = @"https://rpi.sodexomyway.com/dining-choices/res/index.html"; [self getmenuitems:self.url];
in getmenuitems:
//i 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); (tfhppleelement *element in tutorialsnodes) { nslog(@"element: %@", [element text]); }
but tutorialsnodes
comes empty array , im not sure why, can go site in question , put xpath in console , text tuesday: 7:30a - 7:30p
. not being returned code going wrong?
why array nil?
thanks in advance.
Comments
Post a Comment