例如:
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>title</title>
</head>
<body>
<a href="aaa.asp?id=1"> I want to get this text </a>
<div>
<h1>this is my want!!</h1>
<b>this is my want!!!</b>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
结果是:
I want to get this text
this is my want!!
this is my want!!!
Run Code Online (Sandbox Code Playgroud)
Mar*_*ell 31
HtmlDocument doc = new HtmlDocument();
doc.LoadHtml(html);
string s = doc.DocumentNode.SelectSingleNode("//body").InnerText;
Run Code Online (Sandbox Code Playgroud)
die*_*dsp 16
使用此功能......
public string Strip(string text)
{
return Regex.Replace(text, @"<(.|\n)*?>", string.Empty);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
25752 次 |
| 最近记录: |