0
什麼是通過循環獲取所有XML項目並將它們分配給Cell.text作爲數組的最佳方式?iPhone TBXML - 通過響應循環
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *Cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (Cell == nil) {
Cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
}
TBXML * XML = [[TBXML tbxmlWithURL:[NSURL URLWithString:@"http://www.tomstest.info/ios/results.xml"]] retain];
TBXMLElement *rootXML = XML.rootXMLElement;
TBXMLElement *results = [TBXML childElementNamed:@"location" parentElement:rootXML];
TBXMLElement *WOEID = [TBXML childElementNamed:@"CompanyName" parentElement:results];
NSString *woeid = [TBXML textForElement:WOEID];
Cell.text = woeid;
return Cell;
}
感謝
湯姆