1
에서 나는처럼 보이는 HTML 데이터가 : 내가있는 tableView에 링크 제목을 보여줄 수있어구문 분석 HTML 데이터는 jQuery과
<div id="foo"><a class="someClass" href="http://somelink">Some Title</a></div>
<div id="foo"><a class="someClass" href="http://somelink1">Some Title 1</a></div>
<div id="foo"><a class="someClass" href="http://somelink2">Some Title 2</a></div>
,하지만 어떻게 내가 새를로드 이러한 특정 제목의 URL을 얻을 수 있습니다 보기 (테이블 셀 선택시 네비게이션 컨트롤러를 통해 푸시)?
HTMLParser * parser = [[HTMLParser alloc] initWithData:responseData error:&error];
HTMLNode * bodyNode = [parser body];
someArray = [[bodyNode findChildrenWithAttribute:@"id" matchingName:@"someID" allowPartial:NO] retain];
그리고 테이블의 배열 데이터를 표시하려면이 하나 : 여기
내가 HTML 데이터를 구문 분석하는 데 사용하고 코드의- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [someArray count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
}
HTMLNode* someNode = [someArray objectAtIndex:[indexPath row]];
cell.textLabel.text = [NSString stringWithFormat:@"%@",[someNode allContents]];
return cell;
}
매우 가치있는 질문 ... 나는 또한 답변을 기다리고있다. –