Need to replace an img src attrib with new value
See the question and my original answer on StackOverflowXPATH is much more consise than all this XLinq jargon, IMHO... Here is how to do it:
HtmlDocument doc = new HtmlDocument();
doc.Load(myHtml);
foreach (HtmlNode img in doc.DocumentNode.SelectNodes("//img[@src and @height and @width]"))
{
img.SetAttributeValue("src", "http://www.nostrotech.com" + img.GetAttributeValue("src", null));
}
This code searches for img
tags that have src
, height
and width
attributes. Then, it replaces the src
attribute value.