Proper way to change HtmlNode value in document using HtmlAgilityPack

c# html html-agility-pack parsing xpath

Question

Sadly, the code below doesn't work when I try to alter a node's inner html in the document:

HtmlNodeCollection sourceTables = _sourceDoc.DocumentNode.SelectNodes("//table");
sourceTables[0].InnerHtml = "lalala";

The inner html of the node changes correctly, however it doesn't impact the html document.

Additionally, since the node cannot be located, this strategy is ineffective:

_sourceDoc.DocumentNode.ReplaceChild(HtmlNode.CreateNode("<test></test>"), sourceTables[0]);
1
1
9/23/2012 5:40:13 PM

Accepted Answer

This was a significant library flaw (http://htmlagilitypack.codeplex.com/workitem/32959). It has just recently been corrected, at least in the source code (the 1.4.6 version does not have it). You may recompile after running get latest.

1
9/28/2012 4:46:07 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow