First of all my application is not a web application. My aim is reading html files and modify them.
So that I write this code:
string fileName = "~\\ActivationMail.html";
string textLine = string.Empty;
System.IO.StreamReader objReader;
objReader = new System.IO.StreamReader(fileName);
do
{
textLine += objReader.ReadLine();
if (textLine.Contains("id=\"link\""))
{
textLine += "href=\"www.google.com\"";
}
} while (objReader.Peek() != -1);
objReader.Close();
But each time reading whole html file is not seems to best solution. Can I change specific divs without reading(looping) whole html file? Is it possible?
If you are wanting to just change certain things, you could be able to do this with XPath. Using the HTML Agility Pack, you can do this using C#.
http://htmlagilitypack.codeplex.com/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With