【发布时间】:2016-08-22 14:01:25
【问题描述】:
我正在将一些 html 代码作为文本保存到 mysql 数据库中。我使用 volley 将该文本作为字符串检索。当我保存 html 时,某些不需要的值会添加到 html 内容中。如何删除这些不需要的内容并显示 html 内容。我正在使用 webview 来显示此内容并使用 jsoup 来解析它。
这是我使用Document doc = Jsoup.parse(instruction);解析html内容后得到的结果
<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 中。我是编程新手,因此感谢您提供任何帮助或建议。谢谢。
【问题讨论】:
-
@Jens 感谢您的编辑,您能否提供解决方案。
-
PS:锚内不能有 UL