2017-02-10 5 views
-1

こんにちは私は、HTMLコードを取得し、Jsoupで文字列または単語を例文として取得するいくつかの問題があります。 (クラスなし)スパンのあるコードのHTML部分はこれです:Android:どのように取るかテキストなしのクラス属性

<table align="center" width="253"> 
<tbody> 
    <tr> 
    <th style="text-align: center;"> 
    <span style=" font-weight: normal"> 
     Festival 
    </span> 
    <br> 
    </th> 
    </tr> 
</tbody> 
</table> 

私はこのコード

private class ricerca extends AsyncTask<Void, Void, Void> { 
    String phrase; 
    @Override 
    protected void onPreExecute() { 
     super.onPreExecute(); 
    } 

    @Override 
    protected Void doInBackground(Void... params) { 

      try { 
       Document document = Jsoup.connect(url).get(); 

       Elements research = document.select("span[style= font-weight: normal"); 
       phrase = research.attr("span"); 

      } catch (IOException e) { 
       e.printStackTrace(); 
       } 
     return null; 
    } 

    @Override 
    protected void onPostExecute(Void result) { 
     result.setText(phrase); 
    } 

} 

とフレーズ/単語を取るしようとしましたが、のEditTextに」doesnの何もない...なぜ?私のエラーはどこですか?ありがとうございました!

答えて

1

あなたはあなたがまたの最後に閉じ括弧が欠落しているphrase = research.text();
を使用する必要がありますよりも、文字列「祭り」を取得したい場合は - Elements research = document.select("span[style= font-weight: normal");

関連する問題