在 Html Agility Pack 中,当我设置 HtmlNode 的属性时,我应该在从中选择节点的 HtmlDocument 中看到这个吗?
假设 htmlDocument 是一个 HtmlDocument。所以简化的代码如下所示:
HtmlNode documentNode = htmlDocument.DocumentNode;
HtmlNodeCollection nodeCollection = documentNode.SelectNodes(someXPath);
foreach(var node in nodeCollection)
if(SomeCondition(node))
node.SetAttributeValue("class","something");
现在,我看到节点的类属性发生了变化,但我没有看到 htmlDocument 的 html 中反映了这种变化。