Thursday, 21 August 2014

XPath call from iOS not working right



I have the following data



<Table>
<Row>
<Cell><Data>Row Labels</Data></Cell>
<Cell><Data>Searches</Data></Cell>
<Cell><Data>Purchases</Data></Cell>
<Cell><Data>CRatio</Data></Cell>
<Cell><Data>AvgReturn</Data></Cell>
<Cell><Data>Commission</Data></Cell>
</Row>
<Row>
<Cell><Data>2013</Data></Cell>
<Cell><Data>2257224</Data></Cell>
<Cell><Data>18574</Data></Cell>
<Cell><Data>8.2286915255198427E-3</Data></Cell>
<Cell><Data>43.459007223015384</Data></Cell>
<Cell><Data>102390.82995242</Data></Cell>
</Row>
<Row>
<Cell><Data>2014</Data></Cell>
<Cell><Data>5351610</Data></Cell>
<Cell><Data>43035</Data></Cell>
<Cell><Data>8.0415052666393851E-3</Data></Cell>
<Cell><Data>40.420168915503282</Data></Cell>
<Cell><Data>280677.31032664998</Data></Cell>
</Row>
<Row>
<Cell><Data>Grand Total</Data></Cell>
<Cell><Data>7608834</Data></Cell>
<Cell><Data>61609</Data></Cell>
<Cell><Data>8.0970356299007173E-3</Data></Cell>
<Cell><Data>41.336323742293686</Data></Cell>
<Cell><Data>383068.14027907007</Data></Cell>
</Row>


Whats the best way using XPath to get one of data at a time of data and then to get at indiviual elements in that


I have tried the following ...



enter NSArray *rowNodes = [doc nodesForXPath:@"/Table/Row" error:&error];

BOOL doBreak = NO;
@try {


int iRow = 0;
for (GDataXMLElement *rowNode in rowNodes) {
iRow++;

//get cell elements of the row

NSArray* rowCellNodes = [rowNode nodesForXPath:@"//Cell/Data" error:&error];


However when I do this I get the rowNodes correctly, but then I get no results for rowCellNodes in the for loop.


No comments:

Post a Comment