数据抓取时的解析问题

认为我的解析有问题。 我在Android Studio中使用JSoup和Java。 我试图从本地html文件刮取信息并显示在我的应用程序上。 但是,当我运行应用程序时,我想要的数据不会出现。 我想显示“9:00”和“9:15”等时间。 还有“声音”,“P2016”和“P.Mann”。 html看起来像这样:

  timetable.html  body {background-color:white;} body,td { font-family: arial; }    
The Year ICOMWeeks selected for output: 26 (22 Feb 2016-28 Feb 2016)
9:00 9:15 9:30 9:45 10:00 10:15 10:30 10:45 11:00 11:15 11:30 11:45 12:00 12:15 12:30 12:45 13:00 13:15 13:30 13:45 14:00 14:15 14:30 14:45 15:00 15:15 15:30 15:45 16:00 16:15 16:30 16:45
Mon
Sound
P2016 P.Man
22-29, 32-36
       

这就是java的样子:

  import android.app.Activity; import android.os.Bundle; import java.io.File; import java.io.IOException; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; import org.jsoup.select.Elements; import android.widget.TextView; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); try { File input = new File("C:\\Users\\user\\Desktop\\Mobile Newest\\JSoup\\app\\src\\main\\assets\\filename.html"); Document doc = Jsoup.parse(input, "UTF-8"); Elements tableElements = doc.select("td"); TextView textView = (TextView)findViewById(R.id.text_view); for (Element td : tableElements) { textView.setText(td.text()); System.out.println(td.text()); } } catch (IOException e) { e.printStackTrace(); } } } 

任何人都知道它为什么没出现在屏幕上?

问题是,每次调用textView.setText(td.text()) ,textview都会被当前的td.text()替换,所以最后你只能看到你的html的最后一个 td元素文本文件,本质上是一个空格