I'm new in JSoup. I d开发者_如何学Con't know there are any methods for compare similarity 2 tables (or 2 elements as well) in JSoup.
To be specific, suppose that I have 2 tables below: 1 2 3
</table>
<table>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td>4</td>
<td>5</td>
<td>6</td>
</tr>
</table>
So, how I determine that 2 tables might is similar?
Easiest way if you except tables to be 100% similar, then you can do following:
Document doc = Jsoup.parse(yourDocumentHtml);
if(doc.select("table#table1").text().equals(doc.select("table#table2").text()) && doc.select("table#table1").outerHtml().equals(doc.select("table#table2").outerHtml()) )
{
// Tables are equal
}
else
{
// Tables are not equal
}
精彩评论