If all that want to do is count the rows in a table with class "tableClass" then you might try something like this
// Count the number of rows in a particular table
NSString *searchString = [NSString stringWithFormat:@"//table[@class='tableClass']/tr;
NSArray *tableRows = [xpathParser search:searchString];
NSInteger rows = [tableRows count];
NSLog(@"There are %d table Rows", rows);
// For loop to step through the rows
for(int j = 1; j <= rows; j++) {
searchString = [NSString stringWithFormat:@"//table[@class='tableClass']/tr[%d]/td", j];
NSArray *tableCells = [xpathParser search:searchString];
}
This should step through the table row by row and each time scrape the individual data cells (I didn't test it so there are no guarantees.) The problem with this is that it will be very slow if your table has more than a few rows.
You are better off just calling the table and scraping all the td cells at once from the table and then deciding how they make up the rows. This way is easy if the number of cells in a row stays constant.