ChruS
ChruS

Reputation: 3747

Proper way to change HtmlNode value in document using HtmlAgilityPack

I want to change node's inner html in the document but the following code doesn't work unfortunately:

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

The node's inner html changes properly, but it doesn't affect document html.

And this method doesn't work, because the node cannot be found:

_sourceDoc.DocumentNode.ReplaceChild(HtmlNode.CreateNode("<test></test>"), sourceTables[0]);

Upvotes: 1

Views: 1604

Answers (1)

Simon Mourier
Simon Mourier

Reputation: 138960

This was a notable bug in the library (http://htmlagilitypack.codeplex.com/workitem/32959). It has been fixed very recently, at least in the source (it's not in the 1.4.6 release). You can do a get latest and recompile.

Upvotes: 1

Related Questions