【发布时间】:2012-03-12 20:27:13
【问题描述】:
我的问题是我想在收到的电子邮件的 html 中更改一些 src 值。所有这一切都已经完成,我使用 EWS api 建立连接并使用 html 敏捷包进行解析。任何人都知道如何通过我对图像中的 src 值所做的更改来获取 html?
public static string parsearHtml(string body,Item item, ArrayList contentIDS, ArrayList urls)
{
string SRC = "";
int indice = 0;
string retorno = "";
//Console.WriteLine(body);
HtmlDocument email = new HtmlDocument();
email.LoadHtml(body);
foreach (HtmlNode img in email.DocumentNode.SelectNodes("//img"))
{
SRC = img.GetAttributeValue("src", null);
for (int i = 0; i < contentIDS.Count; i++)
{
if (SRC.Equals(contentIDS[i].ToString()))
{
indice = i;
break;
}
}
img.SetAttributeValue("src", urls[indice].ToString());
Console.WriteLine(img.GetAttributeValue("src", null));//in here i get the the attribute and its change so the changing of src values is working
//i tried email.save(retorno) but got error for empty path
//so i tried email.save(body) but got error for illegar characters in path
}
return retorno;
}
【问题讨论】:
标签: c# html-parsing html-agility-pack