如何從此URL獲取所有編號,並在uitableview「http://www.thomas-bayer.com/sqlrest/CUSTOMER/」中顯示。XML解析獲取編號
- (void)viewDidLoad
{
NSURL *URL = [[NSURL alloc] initWithString:@"http://www.thomas-bayer.com/sqlrest/CUSTOMER/"];
NSString *xmlString = [[NSString alloc] initWithContentsOfURL:URL encoding:NSUTF8StringEncoding error:NULL];
xmlDoc = [NSDictionary dictionaryWithXMLString:xmlString];
NSLog(@"dictionary: %@", xmlDoc);
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [xmlDoc count];
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellID = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
if (cell == nil) {
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
}
cell.textLabel.text = [[[xmlDoc objectForKey:@"CUSTOMER"]objectAtIndex:indexPath.row]objectForKey:@"__text"];
return cell;
}
我只得到0,1,2值顯示在uitableview中,並忽略剩餘的ID?
你能告訴我們,你已經試過了嗎? – FelixSFD
我試圖遵循一個非常類似於http://www.theappguruz.com/blog/xmlparsing-with-nsxmlparser-tutorial的xml教程,但最終沒有顯示任何內容。 – RKrish