How can I change all images "src" in a html string in CSQuery?
Here is my code:
CQ HtmlContainingImg = html;
CQ imgTagList = HtmlContainingImg["IMG"];
foreach (var img in imgTagList)
{
string imgsrc = img.Attributes["src"];
if (!IsAbsoluteUrl(imgsrc))
{
//img.Attributes["src", Setting.FelApplicationPath + Setting.folderPath + imgsrc];// this line gives error
// even tried img.Attributes["src"]= Setting.FelApplicationPath + Setting.folderPath + imgsrc;
}
}
this worked for me
CQ HtmlContainingImg = html;
foreach (var img in HtmlContainingImg["IMG"])
{
string imgsrc = img.Attributes["src"];
if (!IsAbsoluteUrl(imgsrc))
{
img.Attributes["src"]= Setting.FelApplicationPath + Setting.folderPath + imgsrc;
}
}
html= HtmlContainingImg.Render(); // I was missing this line