I want to replace ALL HTML special entities like > <
to custom string.
Lets say i have following string:
string str = "<div>>hello<</div>";
and method:
Method(string str, string replaceStr)
After calling Method(str, ":)")
result should be
<div>:)hello:)</div>
The problem is there are too many of special characters and I'm wondering what is the be most efficient way to accomplish this?
EDIT:
String.Replace will not do my work and using Regex for parsing HTML is not really good approach.
By dislikes on this quetion there propably isn't any clean solution therefore I decided go for following algorithm:
- create txt file with valid HTML special characters (like
¶
) - parse file into array of string
- Thanks to HtmLAgilityPack parse HTML and get raw text and replace all entities.
I know that this is not really effective for big html string but it should do the work for now.