Im parsing a table using hpple and libxml2 in an iPhone app. I have encountered a real problem when it comes to finding the column index when sibling cells span multiple rows using colspan.
I saw this question But I can't use jquery to work out the column.
Consider the following table
<table>
<tbody>
<tr>
<td>One</td>
<td>Two</td>
<td id="example1">Three</td>
<td>Four</td>
<td>Five</td>
<td>Six</td>
</tr>
<tr>
<td colspan="2">One</td>
<td colspan="2">Two</td>
<td colspan="2" id="example2">Three</td>
</tr>
<tr>
<td>One</td>
<td>Two</td>
<td>Three</td>
<td>Four</td>
<td>Five</td>
<td>Six</td>
</tr>
</tbody>
</table>
How can i get the column index as 6 NOT 3 for the cell with id 'example1'?
EDIT Added more detail
NSString *xpathQuery = [NSString stringWithFormat:@"1
+ count(//a[contains(@href,'testHref')]
/../preceding-sibling::td[not(@colspan)])
+ sum(//a[contains(@href,'testHref')]/../preceding-sibling::td/@colspan)
+ sum(@colspan)
- count(@colspan)",bookingUrl, bookingUrl];
//Execute XPath
NSArray *array = [parser searchWithXPathQuery:columnCount];