如何删除html标签并将文本发送到没有html标签的msg框 [英] How do i remove html tags and get text to msg box without html tags

查看:84
本文介绍了如何删除html标签并将文本发送到没有html标签的msg框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从网页浏览器文本到消息框获取值

网页浏览器一次只加载两个或三个聊天记录,如wp或wdr



i在文档完成事件中尝试了这个

i want to get values from web browser text to message box
web browser load only two or three chatterers at a time like "wp" or "wdr"

i tried this in document complete event

string body="";
body = webbrowser1.DocumentText;
MessageBox.Show("" + body);





但消息框包含



but message box contain

<div dir="ltr">swr</div>



屏幕截图



i希望删除所有html标签并获取 swr

这样的文字我该怎么办?还有其他方法吗?

提前谢谢


screen shot

i want to remove all html tags and get text like swr
how should i do? have any other method?
thank in advance

推荐答案

我建​​议你这样说:

http://msdn.microsoft.com/en-us/library/ system.text.regularexpressions.regex.replace.aspx [ ^ ]。



然而,整个想法对我来说似乎不太完美。如果某些文本被格式化为HTML,那么它可能是故意在第一时间完成的。从格式化中删除,它可能看起来很难看。为什么不像呈现的HTML一样显示它? CodeProject提供了很棒的组件可以提供帮助:

您将使用的专业HTML渲染器 [ ^ ],

WPF HTML支持的TextBlock [ ^ ]。



-SA
I would advise, for example, this:
http://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex.replace.aspx[^].

However, the whole idea looks like less than perfect to me. If some text is formatted as HTML, it was probably done on purpose in first place. Stripped from formatting, it might look ugly. Why not showing it as is, as rendered HTML? There great components provided at CodeProject could help:
A Professional HTML Renderer You Will Use[^],
WPF HTML Supported TextBlock[^].

—SA


这篇关于如何删除html标签并将文本发送到没有html标签的msg框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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