【发布时间】:2013-12-30 21:09:28
【问题描述】:
我正在尝试使用 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
}
【问题讨论】:
标签: c# html-agility-pack xmldocument