1

我有这个我想抓取的 HTML:

    <textarea name="notes" rows="5" cols="60">some notes go here
    and more including a blank line:

    and another new
    line
    etc
    etc
    </textarea>

因为它们在文本区域中,所以没有 brs 或 \n。我可以很容易地得到全文:

    Element notes = doc.select("textarea[name=notes]").first();
    String notesStr = notes.text();

但是当我想在editText中显示结果时,它作为单行返回,如下所示:

    some notes go here
    and more including a blank line:

    and another new
    line
    etc
    etc
4

1 回答 1

0

尝试这个:

Element notes = doc.select("textarea[name=notes]").first();
String notesStr = notes.getWholeText();

getWholeText():获取此文本节点的(未编码)文本,包括原始文本中存在的任何换行符和空格。

于 2013-10-02T12:04:06.103 回答