Jennifer
Jennifer

Reputation: 23

Parse an <div> of an website to web view

Hey Im trying to take a specific part of an website and then display it on my web view but the problem is when I do that , on smaller screens the letters got all bugged whit accents and stuff , is there any way that I can transfer just a specific div of the website to my web view that is not this bugged one ? The part that I need in this website is called : "inside2"

This is the website: http://www.dges.gov.pt/guias/detcursopi.asp?codc=8184&code=0400

Code that I load the info :

   private class MyTask extends AsyncTask<String, Integer, String> {

    // Runs in UI before background thread is called
    @Override
    protected void onPreExecute() {
        super.onPreExecute();



               }

    // This is run in a background thread
    @Override
    protected String doInBackground(String... params) {
        // get the string from params, which is an array

        Bundle CursoInfoData = getIntent().getExtras();

        site = CursoInfoData.getString("site");

        Document doc = null;
        try {
            doc = Jsoup.connect(site).get();
        } catch (IOException e) {
            e.printStackTrace();
        }
         ele = doc.select(".inside2");
        return "start";
    }

    // This is called from background thread but runs in UI
    @Override
    protected void onProgressUpdate(Integer... values) {
        super.onProgressUpdate(values);

        // Do things like update the progress bar
    }

    // This runs in UI when background thread finishes
    @Override
    protected void onPostExecute(String result) {
        super.onPostExecute(result);
        String text = "<html><head>"
                + "<style type=\"text/css\">body{color: #01A9DB; background-color: #FFFFFF;}"
                + "</style></head>"
                + "<body>"
                + ele.toString()
                + "</body></html>";
        cursoInfoWeb.loadData(text, "text/html", "utf-8");


    }

bugged form that I told you

Upvotes: 2

Views: 52

Answers (1)

Orkhan Alikhanov
Orkhan Alikhanov

Reputation: 10050

You have utf-8 problem I guess. Use this:

cursoInfoWeb.loadDataWithBaseURL(null, text, "text/html", "UTF-8", null);

Reference: SO answer

Upvotes: 2

Related Questions