我的代码使用<a> and </a> <h1> <a> Tags

时间:2015-11-11 12:18:46

标签: android string jsoup

I got my jsoup element to string with this code:

Document likesd;
    try {

        likesd = Jsoup.connect(site).ignoreContentType(true).get();
        Elements links = likesd.select("h1");
        Element likess=links.select("a").first();

        mcpe=likess.toString();
    } catch (IOException ex) {}

And printed to sharedpreferences with this code.

Button button = (Button) findViewById(R.id.pp);
    button.setOnClickListener(new OnClickListener(){
            @Override
            public void onClick(View view) {

                preferencess=PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
                editorr = preferencess.edit();
                editorr.putString("build4", mcpe);
            be=preferencess.getString("build4", mcpe);
                editorr.commit();
            }
        });

site's code:

<!DOCTYPE html>

<meta charset="UTF-8" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>cikti</title>
        <h1><a>http://i.androyun.xyz/11</a></h1>
<h2>MCPE 0.13.0 Build 1</h2>

kk

But output of this code in my sharedpref.xml,

  <string name="build4">&lt;a&gt;http://i.androyun.xyz/11&lt;/a&gt;</string>

But I dont want <a> text. What should I do? Thanks to all ^^

1 个答案:

答案 0 :(得分:0)

请尝试mcpe=likess.text();

并阅读:http://jsoup.org/cookbook/extracting-data/attributes-text-html