Is there a way to extract only the Table (TagName: tbody) from a specific webpage? The link to the webpage is here:
I've been following a tutorial on how to do this at , but I'm running into some issues. Can anyone provide assistance?
Here's the code snippet that I've tried:
public class Stundenplan extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final Context myApp = this;
class MyJavaScriptInterface
{
@SuppressWarnings("unused")
public void showHTML(String html)
{
new AlertDialog.Builder(myApp)
.setTitle("HTML")
.setMessage(html)
.setPositiveButton(android.R.string.ok, null)
.setCancelable(false)
.create()
.show();
}
}
final WebView browser = (WebView)findViewById(R.id.webView);
browser.getSettings().setJavaScriptEnabled(true);
browser.addJavascriptInterface(new MyJavaScriptInterface(), "HTMLOUT");
browser.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url)
{
browser.loadUrl("javascript:window.HTMLOUT.showHTML('<head>'+document.getElementsByTagName('tbody')[0].innerHTML+'</head>');");
}
});
browser.loadUrl("http://info.tam.ch/custom/stpl_klw.php");
}