This project has moved and is read-only. For the latest updates, please go here.

Changing Attributes Not Reflected in InnerHtml

Topics: Developer Forum, User Forum
Aug 13, 2007 at 10:19 PM
I'm trying to fix some links, but when I change an attribute the parent nodes' InnerHtml is not updated to reflect this change.

HtmlNodeCollection links = MyNode.SelectNodes("//a");

foreach (HtmlNode link in links)
HtmlAttribute href = link.Attributes"href";
if (href != null)
href.Value = "" + href.Value;

The code executes, but at the end of the loop MyNode.InnerHtml hasn't changed. What could be going on?
Aug 13, 2007 at 10:23 PM
Even if I refetch "MyNode" from the document, its content still hasn't changed:

MyNode2 = MyNode.OwnerDocument.DocumentNode.SelectSingleNode(...)

MyNode2's InnerHtml is the same as MyNode's, so this isn't just an issue of updates not being "live" between class instances.