html - Parse <tr> block into UITableCell -


i'm using hpple parse html of website onto app. parsing working great instead of contents of tr block in 1 cell, each of td elements in tr block table cells of own. here's mean. tr block:

<tr>                     <td>2</td>                     <td>down 1</td>                     <td>1</td>                     <td>5</td>                     <td>justin bieber</td>                     <td>what mean?</td>                 </tr> 

what looks in app:
enter image description here

when want this: enter image description here

the code i'm using parsing looks this:

 - (void)loadsongs { // 1 nsurl *tutorialsurl = [nsurl urlwithstring:@"http://www.bbc.co.uk/radio1/chart/singles/print"]; nsdata *tutorialshtmldata = [nsdata datawithcontentsofurl:tutorialsurl];  // 2 tfhpple *tutorialsparser = [tfhpple hpplewithhtmldata:tutorialshtmldata];  // 3 nsstring *tutorialsxpathquerystring = @"//tr/td"; nsarray *tutorialsnodes = [tutorialsparser searchwithxpathquery:tutorialsxpathquerystring];  // 4 nsmutablearray *newtutorials = [[nsmutablearray alloc] initwithcapacity:0]; (tfhppleelement *element in tutorialsnodes) {     // 5     tutorial *tutorial = [[tutorial alloc] init];     [newtutorials addobject:tutorial];      // 6     tutorial.title = [[element firstchild] content];    tutorial.peakposition = ???;   }  // 8 _objects = newtutorials; [self.tableview reloaddata]; } 

try nsstring *tutorialsxpathquerystring = @"//tr[contains(td, *)]";

see here more functions: w3schools

this website testing xpath syntax

hope helps :)

update:

the reason why nil because didn't html data url instead of xpath.

and reason why can't data because app transport security.

please check link: how load http url app transport security enabled in ios 9?

add following plist file.

<key>nsapptransportsecurity</key> <dict> <key>nsallowsarbitraryloads</key> <true/> </dict> 

it should working : )


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -