相关疑难解决方法(0)

如何从ASP.NET中的字符串中剥离HTML标记?

使用ASP.NET,如何可靠地从给定字符串中剥离HTML标记(即不使用正则表达式)?我正在寻找像PHP这样的东西strip_tags.

例:

<ul><li>Hello</li></ul>

输出:

"你好"

我试图不重新发明轮子,但到目前为止我还没有找到满足我需求的东西.

html c# regex asp.net string

122
推荐指数
6
解决办法
13万
查看次数

从字符串中删除HTML标记,包括C#中的

如何删除所有HTML标记,包括在C#中使用正则表达式.我的字符串看起来像

  "<div>hello</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div>"
Run Code Online (Sandbox Code Playgroud)

html c# regex string

82
推荐指数
3
解决办法
12万
查看次数

HTML敏捷包 - 删除不需要的标签而不删除内容?

我在这里看到了一些相关的问题,但他们并没有完全谈论我面临的同样问题.

我想使用HTML Agility Pack从HTML中删除不需要的标记,而不会丢失标记中的内容.

例如,在我的场景中,我想保留标签" b"," i"和" u".

并输入如下:

<p>my paragraph <div>and my <b>div</b></div> are <i>italic</i> and <b>bold</b></p>

生成的HTML应为:

my paragraph and my <b>div</b> are <i>italic</i> and <b>bold</b>

我尝试使用HtmlNodeRemove方法,但它也删除了我的内容.有什么建议?

c# html-agility-pack

44
推荐指数
4
解决办法
4万
查看次数

删除String中的HTML标记

如何从以下字符串中删除HTML标记?

<P style="MARGIN: 0cm 0cm 10pt" class=MsoNormal><SPAN style="LINE-HEIGHT: 115%; 
FONT-FAMILY: 'Verdana','sans-serif'; COLOR: #333333; FONT-SIZE: 9pt">In an 
email sent just three days before the Deepwater Horizon exploded, the onshore 
<SPAN style="mso-bidi-font-weight: bold"><b>BP</b></SPAN> manager in charge of 
the drilling rig warned his supervisor that last-minute procedural changes were 
creating "chaos". April emails were given to government investigators by <SPAN 
style="mso-bidi-font-weight: bold"><b>BP</b></SPAN> and reviewed by The Wall 
Street Journal and are the most direct evidence yet that workers on the rig 
were unhappy …
Run Code Online (Sandbox Code Playgroud)

html c#

33
推荐指数
2
解决办法
8万
查看次数

如何使用C#清理HTML标记

例如:

<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)

html c#

23
推荐指数
2
解决办法
3万
查看次数

C# HTML 字符串 -&gt; 不使用 html 获取长度

我有包含 HTML 图像的字符串,例如:

string str = "There is some nice <img alt='img1' src='img/img1.png' /> images in this <img alt='img2' src='img/img2.png' /> string. I would like to ask you <img alt='img3' src='img/img3.png' /> how Can I can I get the Lenght of the string?";
Run Code Online (Sandbox Code Playgroud)

我想获取没有图像的字符串长度和图像数量。所以,结果应该是:

int strLenght = 111;
int imagesCount= 3;
Run Code Online (Sandbox Code Playgroud)

请问您能告诉我最有效的方法吗?

谢谢

html c# string image

5
推荐指数
1
解决办法
2131
查看次数

C#正则表达式解析HTML

我的价值1

我需要"我的价值1"请帮助我.C#语言

html c# regex

0
推荐指数
1
解决办法
6300
查看次数

标签 统计

c# ×7

html ×6

regex ×3

string ×3

asp.net ×1

html-agility-pack ×1

image ×1