我将一些html代码保存为mysql数据库中的文本。我使用volley检索这个文本作为字符串。当我保存html时,某些不需要的值被添加到html内容中。如何删除这些不需要的内容并显示html内容?我使用webview来显示此内容,并使用jsoup来解析它。这是我使用Document doc = Jsoup.parse(instruction);
<html>
<head></head>
<body>
{"result":[{"instruction":"nnu00a0 u00a0</head>nnu00a0 u00a0nnu00a0 u00a0 u00a0
<ul>
nnu00a0 u00a0 u00a0 u00a0 u00a0
<li>The Comprehensive R Archive Network</li>nnu00a0 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>nnu00a0 u00a0 u00a0 </ul>nnu00a0 u00a0 u00a0
<p><br ="" /><strong>Download and Install R:</strong></p>nnu00a0 u00a0 u00a0 </strong></p>
<ul>
<strong>
nnu00a0 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>nnu00a0 u00a0 u00a0 u00a0 u00a0</a></li>
<li>
<a href=""url"">
Select one of the three download links according to your machine.</li>nnu00a0 u00a0 u00a0 </ul>nnu00a0 u00a0 u00a0 <img src=""file:///storage/emulated/0/rreadyreckoner_images/download-r.png"" alt=""downloadr"" width=""191"" height=""129"" ="" />u00a0nnu00a0 u00a0 u00a0
<ul>
nnu00a0 u00a0 u00a0 u00a0 u00a0
<li>Run the R set up and follow the instructions of the installer.</li>nnu00a0 u00a0 u00a0 </ul>nnu00a0 u00a0</body>nn</html>nn"}]} </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获取