I have a HTML text as input, keyword as input and URL address as input also.
How should i find that keyword in the text and surround it with anchor element, putting the URL in the href attribute and the keyword in the InnerText part of the element?
Notice that the keyword can’t be an attribute of some other element in the HTML text
and also it can’t be already inside an anchor (already within a link).
A tool commonly recommended for this is the Html Agility Pack. It will take malformed HTML and massage it into XHTML and then a traversable DOM, so is very useful for the code you find in the wild, as opposed to approaches like RegEx, which are destined to break.
There are some examples and the API documentation here:
http://html-agility-pack.net/api
Some useful links: