I need help parsing an html file from my schools website, I know this code is bad BUT there is hardly any decent tutorial on html parsing for android so I ATTEMPTED this. I am still in the beginning of my software stages so bare with me! Thanks! ^-^

package com.example.test;

import java.io.IOException;

import android.os.Bundle;
import org.jsoup.Jsoup;
import org.jsoup.helper.Validate;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import android.app.Activity;
import android.view.Menu;
import android.view.MenuItem;
import android.support.v4.app.NavUtils;

public class Parsing extends Activity {
Document doc;
Element Link;
String linkhref;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        try {
            Document doc = Jsoup.connect("www.csn.edu/events.asp").get();
        } catch (IOException e) {
            System.out.print("failed");
            e.printStackTrace();
        }

        Element link= doc.select("table.cal-StudentActivitiesandEvents-row").first();
       linkhref=link.attr("href");


    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }


}

Recommended Answers

What exactly you trying to achive(you said parse html but that is not enough) or what sort of data and what format you want to get this out as...

Jump to Post

All 3 Replies

What exactly you trying to achive(you said parse html but that is not enough) or what sort of data and what format you want to get this out as...

I want to parse the Events sections. I need to parse all of the Text stating the different events

The Events section of the site I am trying to parse is actually at www.csn.edu/news/events

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.