作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我将一些 html 代码作为文本保存到 mysql 数据库中。我使用 volley 将此文本作为字符串检索。当我保存 html 时,某些不需要的值会添加到 html 内容中。如何删除这些不需要的内容并显示 html 内容。我正在使用 webview 来显示此内容并使用 jsoup 来解析它。这是我使用 Document doc = Jsoup.parse(instruction);
<html>
<head></head>
<body>
{"result":[{"instruction":"\n\n\u00a0 \u00a0<\/head>\n\n\u00a0 \u00a0\n\n\u00a0 \u00a0 \u00a0
<ul>
\n\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0
<li>The Comprehensive R Archive Network<\/li>\n\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0</li>
<li>
A network of global web servers storing identical, up-to-date, versions of<br \="" />code and documentation for R<\/li>\n\n\u00a0 \u00a0 \u00a0 <\/ul>\n\n\u00a0 \u00a0 \u00a0
<p><br \="" /><strong>Download and Install R:<\/strong><\/p>\n\n\u00a0 \u00a0 \u00a0 </strong></p>
<ul>
<strong>
\n\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0
<li>Use the CRAN mirror nearest to you to download R setup at a faster<br \="" />speed. Go to <a href="\"url\"">\u00a0http:\/\/cran.r-project.org<\/a><\/li>\n\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0</a></li>
<li>
<a href="\"url\"">
Select one of the three download links according to your machine.<\/li>\n\n\u00a0 \u00a0 \u00a0 <\/ul>\n\n\u00a0 \u00a0 \u00a0 <img src="\"file:\/\/\/storage\/emulated\/0\/rreadyreckoner_images\/download-r.png\"" alt="\"downloadr\"" width="\"191\"" height="\"129\"" \="" />\u00a0\n\n\u00a0 \u00a0 \u00a0
<ul>
\n\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0
<li>Run the R set up and follow the instructions of the installer.<\/li>\n\n\u00a0 \u00a0 \u00a0 <\/ul>\n\n\u00a0 \u00a0<\/body>\n\n<\/html>\n\n"}]} </li>
</ul>
</a>
</li>
</strong>
</ul>
</li>
</ul>
</body>
</html>
有没有一种方法可以将 html 内容检索为字符串,然后将其重构为纯 html 并将其显示在 webview 中。我是编程新手,因此不胜感激任何帮助或建议。谢谢。
最佳答案
您可以使用 org.apache.commons.lang3.StringEscapeUtils.unescapeJava(text)
转义 unicode 字符,例如 \u00a0
和 org.apache.commons .lang3.StringEscapeUtils.unescapeHtml4(text)
转义 html 编码字符,如 "
。
StringEscapeUtils
类可以从Apache Commons获得.
关于java - 如何在java中恢复html内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39072084/
我是一名优秀的程序员,十分优秀!