Android 如何解析类似这种标签中的数据

json串"context":"<p>2019.11.12 北京门店宿舍检查结果公布</p><p><img src="/ueditor/jsp/upload/image/20191112/1573554453343096382.png" title="1573554453343096382.png" alt="blob.png"/></p>",

json串只贴了关键代码

jar包下载地址链接: https://pan.baidu.com/s/1Pf1cuIBp3rBe69RGGNm9Zw 提取码: i5c8链接: 

1.下载jar包,添加依赖

2.

String context = systemMessage.getContext();
Document parse = Jsoup.parse(context);
Element p = parse.getElementsByTag("p").get(0);
String text = p.text();//获取标签中的文字

tv_context.setText(text);//把文字设置到TextView上
Element e_form = parse.getElementsByTag("p").get(1);
Elements img = e_form.getElementsByTag("img");
String src = img.attr("src");//获取标签中的img属性

参考链接:https://zhidao.baidu.com/question/123669556.html

发布了154 篇原创文章 · 获赞 36 · 访问量 22万+

猜你喜欢

转载自blog.csdn.net/yijiaodingqiankun/article/details/103409120