这个问题已经在这里有一个答案:
我试图解析HTML表格。我在做它的方式是通过在RecyclerView.xml单独解析每列的项目。但是,我似乎只能通过硬编码数,找到每个单词:f.ex .EQ(1),.EQ(2)。你将如何实现自动化吗?
for (int i = 0; i < mElementSize; i++) { // Strekning
Elements mElementAuthorName = mBlogDocument.select("table.ctckeditortable:contains(Område nord) > tbody > tr > td").eq(1);
String mAuthorName = mElementAuthorName.text();
// Dato
Elements mElementBlogUploadDate = mBlogDocument.select("table.ctckeditortable:contains(Område nord) > tbody > tr > td").eq(1);
String mBlogUploadDate = mElementBlogUploadDate.text();
// Navn
Elements mElementBlogTitle = mBlogDocument.select("table.ctckeditortable:contains(Område nord)").select("td").eq(i);
String mBlogTitle = mElementBlogTitle.text();
mGatenavnList .add(mAuthorName);
mStrekningList.add(mBlogUploadDate);
mDatoList.add(mBlogTitle);
}
我试着使用公式(我),所以我会自动寻找每一个栏,由数数量。 :/
你应该考虑JSoup对于这样的HTML解析问题。你应该尝试制定其选择,然后可以遍历并且适用于RecyclerView元素的集合的表达式。