Android的JSoup编辑文本标记 [英] Android JSoup editing text tag

查看:164
本文介绍了Android的JSoup编辑文本标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎样才能获取文本是这样的:

How can I get the text like this:

<body>
hi
</body>

使其粗体即可。
 我已经尝试了一些,但没有工作不同的东西,主要是因为标签我尝试使用添加

and make it bold. I have tried a number of different things that have not worked, mainly because the tags I try to add with

element.wrap();

在错误的地方添加。

推荐答案

这对我的作品:

    String html = "<html><body>hi</body></html>";

    Document doc = Jsoup.parse(html);
    Element body = doc.select("body").first();

    body.html("<b>" + body.text() + "</b>");

这篇关于Android的JSoup编辑文本标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆