How to remove all <a></a> tags from a large html string in C#?
I have a large string of HTML that I have parsed with a bunch of already formed links in it. I am looking for a quick way to get rid of all of the links to display just the text. Any help or suggestions is appreciated!
Sample html string looks like this:
<A href="test.com">myText</A>, <A href="test1.com">myText</A>, <A href="test2.com">myText</A>, <A href="differenttesturl.co开发者_运维问答m">myText</A>, <A href="test0.com">myText</A>
I want the HTML to look like this when it's done:
myText, myText, myText, myText, myText
I'm using C# on an ASP.NET page and have the HTML stored as a STRING,
Thanks.
Here is a simple solution for stripping HTML tags from a string using Regular expressions.
http://www.osherove.com/blog/2003/5/13/strip-html-tags-from-a-string-using-regular-expressions.html
You could turn it into an XML document and extract all the Text nodes.
You want to use an HTML parser to do this.
See this post for some options
Looking for C# HTML parser
精彩评论