RemoveChild?

Topics: User Forum
Oct 27, 2009 at 2:28 PM
Edited Oct 27, 2009 at 2:30 PM

Could someone explain why this would fail? Am I thinking about it wrong? I'd like to purge a tag and all its children, but put a marker for later reference. I'm getting a System.ArgumentOutOfRangeException: Node "<div id="search"></div>" was not found in the collection error. The node is clearly being found, but maybe not during replace?

_doc.DocumentNode.ReplaceChild(
	HtmlNode.CreateNode("<!-- removed search -->"),
	_doc.DocumentNode.SelectSingleNode("//div[@id='search']")
);