如何将 Html 转换为纯文本? [英] How do you convert Html to plain text?

查看:45
本文介绍了如何将 Html 转换为纯文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将 Html 片段存储在一个表中.不是整个页面,没有标签或类似的东西,只是基本的格式.

I have snippets of Html stored in a table. Not entire pages, no tags or the like, just basic formatting.

我希望能够在给定页面上仅将 Html 显示为文本,没有格式(实际上只是前 30 - 50 个字符,但这很简单).

I would like to be able to display that Html as text only, no formatting, on a given page (actually just the first 30 - 50 characters but that's the easy bit).

如何将 Html 中的文本"作为纯文本放入字符串中?

How do I place the "text" within that Html into a string as straight text?

所以这段代码.

<b>Hello World.</b><br/><p><i>Is there anyone out there?</i><p>

变成:

你好世界.外面有人吗?

Hello World. Is there anyone out there?

推荐答案

如果你在谈论标签剥离,如果你不必担心诸如

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