Currently I'm following Ray Wenderlich's tutorial dealing with parsing html on ios. Everything is explained perfectly and according to this tree:
(source: raywenderlich.com)
they extract the title and url tag for each tutorial.
This is how they create an array to hold their Tutorial object:
NSMutableArray *newTutorials = [[NSMutableArray alloc] initWithCapacity:0];
for (TFHppleElement *element in tutorialsNodes) {
// 5
Tutorial *tutorial = [[Tutorial alloc] init];
[newTutorials addObject:tutorial];
// 6
tutorial.title = [[element firstChild] content];
// 7
tutorial.url = [element objectForKey:@"href"];
}
Now here is my question. I'm currently trying this out on my site. The problem is that I don't know how to get the 4th child of every <tr>
tag.
Here is my html tree.
I'm trying to only get that fourth child from every tag. But I don't know how to approach it.
Would this be correct?
// 6
tutorial.title = [[element firstChild] content];
// 7
tutorial.amount = [[element fourthChild] objectForKey:@"td"];