Html.fromHtml不会移除<! - comments - > [英] Html.fromHtml does not removes <!-- comments -->

查看:196
本文介绍了Html.fromHtml不会移除<! - comments - >的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在解析一些HTML代码,我想放入一个Textview。 (Webview太多,我只想要一些非常简单的东西)。

I am currently parsing some HTML code and I would like to put in a Textview. (Webview is too much, I just want something very simple).

Html.fromHtml(mySource)伟大和工作罚款。
此行使我的文本变成颜色,粗体,斜体等...

The Html.fromHtml(mySource) is great and working fine. This line makes my text turn in colors, bold, italic, etc...

不幸的是,它有一些不便,它不会删除评论。

Unfortunately, it has some inconvenients, it does not remove the comments.

除了使用WebView之外,您有其他任何解决方案吗?

Do you have any solution other than using a WebView?

>

推荐答案

在将字符串传递给 Html.fromHtml()之前,自行删除注释。是否使用正则表达式或HTML解析器取决于您,但这位先生对此事有意见

Remove the comments yourself before passing the string to Html.fromHtml(). Whether you use a regular expression or an HTML parser is up to you, though this gentleman has an opinion on the matter.

这篇关于Html.fromHtml不会移除<! - comments - >的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆