Why can't HtmlAgilityPack for .NET Core 1.5.0.1 find HtmlWeb? Is there a known workaround or a right/better way to do this?

.net-core c# html-agility-pack

Question

I'm trying to use HtmlAgilityPack for .NET Core 1.5.0.1 since HtmlAgilityPack version 1.4.9.5 seems to be incompatible with my .NET Core v1.0 project, but I'm getting an error when trying to declare a HtmlWeb object:

HtmlWeb htmlWeb = new HtmlWeb();
HtmlDocument htmlPage = htmlWeb.Load(url);
HtmlNode allItems = htmlPage.GetElementbyId("allItems");

Error message: "The type or namespace name 'HtmlWeb' could not be found (are you missing a using directive or an assembly reference?)"

I'm seeing some other classes like HtmlEntity, HtmlNodeCollection, HtmlNodeNavigator in 1.5.0.1, but not sure how they work.

Does HtmlAgilityPack 1.5.0.1 intentionally not include the HtmlWeb class? How do I write 1.5.0.1 code that accomplishes what the code above does, which works in 1.4.9.5? Is there some documentation somewhere about how to use 1.5.0.1?

Popular Answer

The original HtmlAgilityPack is still at 1.4.9.5 and it does not support .Net Core.

The package you are using is a fork by Simon Mourrier and Jeff Klawiter and it does not support the HtmlWeb class.

There is another fork that you may want to try because it has a partial implementation of HtmlWeb. You may want to check it's source code on github.



Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why