gpt4 book ai didi

android - json解析将html标签转为转义序列

转载 作者:太空狗 更新时间:2023-10-29 12:53:43 30 4
gpt4 key购买 nike

我正在从使用 JSON 解析的服务器中获取一些 html 内容。但这会将我的 html 内容转换为 unicode 值。

例如:<p>Spend minimum $10 (in a single same-day receipt) at any outlet<\/p>正在转换为,

;p&gt;Spend minimum $10 (in a single same-day receipt) at any outlet &lt;/p&gt;

现在,如果我尝试将其设置为我的 WebView,它会显示 HTML 标签本身。如果我尝试使用 TextUtils.encode 对数据进行编码它显示具有 unicode 值的文本。

谁能帮我解决这个问题。

我应该如何获取 HTML 内容并将其显示在 WebView 中?

最佳答案

我没有完全理解你的问题,但是,如果你想在 web View 中加载 HTML,你可以使用

webView.loadDataWithBaseURL(null, html, "text/html", "UTF-8", null);

如果您想转换 < 和 > 之类的符号,您可以使用 Jsoup图书馆

关于android - json解析将html标签转为转义序列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9156583/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com