-1
Jsoup를 사용하여 HTML 문자열에서 데이터를 가져 오려고했지만 성공하지 못했습니다. HTML 코드Jsoup은 항상 null을 반환합니다.
<form>
<table>
<tr>
<th>First</th>
<th>Second</th>
<th>Third</th>
</tr>
<tr>
<td><input type="text" name="elems[][f]" value="one" /></td>
<td><input type="text" name="people[][s]" value="two" /></td>
<td><input type="text" name="people[][t]" value="three" /></td>
</tr>
<tr>
<td><input type="text" name="elems[][f]" value="one1" /></td>
<td><input type="text" name="people[][s]" value="two2" /></td>
<td><input type="text" name="people[][t]" value="three3" /></td>
</tr>
</table>
<input type="submit" value="next" />
내가 다른 케이스를 시도했습니다
, 불과하다. 나는 th와 모든 td에서 데이터를 검색 할 것이다. ...이 같은 문자열 변수로 HTML 입력을 배치하면
이Document document = Jsoup.parse(HTMLSTring);
Elements tables = document.select("table");
for (Element table : tables){
Elements ths = table.getElementsByTag("th");
for(Element th : ths)
{
System.out.println(th.text());
}
}
먼저 'tr'을 확인할 필요가 없습니까? –
올바른 * '
'getElementsByTag'가 반복적이기 때문에'tr'을 먼저 검사 할 필요가 없습니다. 코드가 작동합니다 ... JSoup이 'null'을 반환하는 것이 아닙니다. 'HTMLSTring'에 올바른 html 콘텐츠를 받았는지 확인 했습니까? – Nirekin
답변
귀하의 코드가 작동 :
이은 당신이 예상 한 것이 "일"에 대한 예입니다 결과.
첫째.
예를 들어, 에 중단 점을 입력하여 올바른 내용을 수신해야합니다.
출처
2017-10-19 09:31:00 Nirekin
관련 문제