Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net 获取非html文本值_.net_Vb.net - Fatal编程技术网

.net 获取非html文本值

.net 获取非html文本值,.net,vb.net,.net,Vb.net,我从存储html值的数据库中获取数据,我只想获取没有html元素的文本 Me.txtArea1.InnerHtml = _subject + _body 当我这样做时,值显示为 subject <p>body</p> 受试者身体 在顶部导入正则表达式: Imports System.Text.RegularExpressions 然后,像这样使用: Me.txtArea1.InnerHtml = _subject + Regex.Replace(_body,

我从存储html值的数据库中获取数据,我只想获取没有html元素的文本

Me.txtArea1.InnerHtml = _subject +  _body 
当我这样做时,值显示为

subject <p>body</p>
受试者身体

在顶部导入正则表达式:

Imports System.Text.RegularExpressions
然后,像这样使用:

Me.txtArea1.InnerHtml = _subject +  Regex.Replace(_body, "<.*?>", "")
Me.txtArea1.InnerHtml=\u subject+Regex.Replace(\u body,“,”)
您可以使用它从DB解析html

string html = "subject <p>body</p>";
var doc = new HtmlAgilityPack.HtmlDocument();
doc.LoadHtml(html);
string textOnly = doc.DocumentNode.InnerText; // "subject body"
string html=“subjectbody

”; var doc=new HtmlAgilityPack.HtmlDocument(); doc.LoadHtml(html); 字符串textOnly=doc.DocumentNode.InnerText;//“主体”