Html Agility Pack: Setting an HtmlNode's Attribute Value isn't reflected in the HtmlDocument.

Posted by Avi on Stack Overflow See other posts from Stack Overflow or by Avi
Published on 2011-01-04T01:34:08Z Indexed on 2011/01/04 1:54 UTC
Read the original article Hit count: 218

In Html Agility Pack, when I set an attribute of an HtmlNode, should I see this in the HtmlDocument from which the node was selected?

Lets say that htmlDocument is an HtmlDocument. So the simplified code looks like this:

HtmlNode documentNode = htmlDocument.DocumentNode;
HtmlNodeCollection nodeCollection = documentNode.SelectNodes(someXPath);
foreach(var node in nodeCollection)
   if(SomeCondition(node))
       node.SetAttributeValue("class","something");

Now, I see the class attribte of node change, but I don't see this change reflected in the htmlDocument's html.

© Stack Overflow or respective owner

Related posts about htmlagilitypack

Related posts about setattribute