我正在使用AFNetworking来获取JSON响应并根据它填充我的UITableView。但是,我在某些JSON响应中获取了诸如<a href='link'>
之类的HTML标记。如何删除它们并在填充我的tableview单元格时获得正确的格式?使用AFNetworking从JSON响应解析HTML标记
下面是使用AFNetworking从JSON响应的tableview重新加载数据的代码 -
NSURL *url = [NSURL URLWithString:@"http://xxxxx.com/api.php?req=all"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id responseObject) {
self.jobsArrayFromAFNetworking = [[responseObject objectForKey:@"all"]mutableCopy];
[spinner stopAnimating];
[self.tableView reloadData];
NSLog(@"JSON RESULT %@",responseObject);
}failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id responseObject){
NSLog(@"Request failed with error: %@, %@",error,error.userInfo);
}];
[operation start];
}
我不清楚:你想从数据中去掉HTML标签,以便它们不会直接渲染到你的表格视图单元格中吗? – adpalumbo
我希望html标签以正确的方式出现。间接地,我想从JSON响应到处解析这些html标签。 –
所以你想呈现HTML标记,以便格式显示在你的表格视图单元格中? – adpalumbo