I have a string that contains html code of a document.
It can have multiple image tags inside.
What I want to do is to pass the img tag’s src attribute value i.e. url to a C# function and replace that value with the function returns.
How can I do this?
Regex is not a good for parsing HTML files.HTML is not strict nor is it regular with its format.(for example: in non strict html its OK to have a tag without a closing tag)
Use htmlagilitypack
You can use
htmlagilitypackto do it like this