0
嗨我正在試驗如何使用正則表達式使用HTMLAgilityPack V(不知道哪個更昂貴)。我與HTMLAgilityPack問題ID我能夠提取所需的屬性,並用新的替換它;但是,我似乎不能更新原文。這是代碼;C#:找到HTML屬性並使用HTMLAgilityPack替換值
string input = @"<area shape=""rect"" coords=""0,0,82,126"" href=""one"" alt=""Sun""> <area shape=""rect"" coords=""0,0,82,126"" href=""two"" alt=""Sun"" > <area shape=""rect"" coords=""0,0,82,126"" href=""Three"" alt=""Sun"" >";
HtmlDocument document = new HtmlDocument();
document.LoadHtml(input);
HtmlNodeCollection nodes = document.DocumentNode.SelectNodes("//area");
for (int i = 0; i < nodes.Count; i++)
{
HtmlNode node = nodes[i];
var href = node.Attributes["href"].Value;
//Reassigning href value
node.Attributes["href"].Value="Re-Assign ["+i+"]";
}
現在我想使這反映在原來的「輸入」變量。任何想法如何繼續?
感謝