I need some help to keep line breaks when parsing html using Jsoup.
I have already tried researching and trying things that were on this website, however could not find any of them to work.
I am very new to coding, so easy explanations are more welcomed.
Thanks in advance!
public class MainActivity extends AppCompatActivity {
TextView content;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
content=(TextView)findViewById(R.id.content0);
Button but=(Button) findViewById(R.id.but1);
but.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
System.out.println("parse button pressed");
new doit().execute();
}
});
}
public class doit extends AsyncTask<Void,Void,Void>{
String words;
@Override
protected Void doInBackground(Void... params) {
System.out.println("parsing");
try {
Document doc = Jsoup.connect("http://daltonschool.kr/homeeng/04schoollife/040203schoollife.html").get();
words=doc.select("table.cafeteria tbody tr td").eq(3).text();
}catch(Exception e){e.printStackTrace();}
return null;
}
@Override
protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid);
content.setText(words);
}
}
}