如何从此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