我正在尝试使用HtmlAgilityPack更新外��HTML。但是该属性为只读。我的问题是如何更新外部HTML?注意:我需要更新外部HTML(不仅仅是内部HTML)。以下是代码:
// Check if there is a nested table
HtmlAgilityPack.HtmlNode nestedtable = tr.SelectSingleNode(".//table");
if (nestedtable != null)
{
// Save Inner/Outer Html and update Outer Html
string strInnerHtml = nestedtable.InnerHtml;
string strOuterHtml = nestedtable.OuterHtml;
string strNewOuterHtml = "<table><tr><td><table><tr><td>inner1update</td><td>inner2update</td></tr></table></td></tr></table>";
// Now update source HtmlDocument
nestedtable.OuterHtml = strNewOuterHtml;
// ^^^ Error line: Property or indexer
//HtmlAgilityPack.HtmlNode.OuterHtml' cannot be assigned to -- it is read only
}