I’m trying to return multiple rows from xml data. I have loaded the result into a dictionary. The code below gives me the last result (row 1 or Randy). How do I retrieve all of the results instead of just the last one? I’m looking for CSHR_POS_NAME where [ID.text intValue] == CSHR_NUM.
dict = [resp objectForKey:@"TC"];
if( ( dict == nil ) || ![dict isKindOfClass:[NSDictionary class]] ) {
NSLog( @"WARNING: %@", [dict description]);
return;
}
desc = [[dict objectForKey:@"CSHR_POS_NAME"]copy];
CashierNum = [[dict objectForKey:@"CSHR_NUM"]copy];
NSLog(@"Name: %@ and Cashier Number: %@",desc, CashierNum);
the log for the xml output is:
<NewDataSet xmlns="">
<TC diffgr:id="TC1" msdata:rowOrder="0">
<CSHR_POS_NAME>BRITTANY</CSHR_POS_NAME>
<CSHR_NUM>66</CSHR_NUM>
</TC>
<TC diffgr:id="TC4" msdata:rowOrder="1">
<CSHR_POS_NAME>Randy</CSHR_POS_NAME>
<CSHR_NUM>7</CSHR_NUM>
</TC>
</NewDataSet>
</diffgr:diffgram>
It seems you have an array of dictionaries with the
"TC"key. Should you not be trying to read the response as an array, and then iterate through the dictionaries?