I'm working with the HtmlAgilityPack library and trying to understand how to load it in PowerShell. I typically load it using `Add-Type -path ".HtmlAgilityPack.dll"` and I expect to see method suggestions when I type `[HtmlAgilityPack.HtmlDocument]::loadHt...`. However, I'm not seeing any suggestions for methods. On the other hand, when I create an object with `New-Object HtmlAgilityPack.HtmlDocument`, I do get method suggestions. Can anyone explain why `[HtmlAgilityPack.HtmlDocument]` isn't showing the methods like `new-object` does? I'm currently using PowerShell version 7.4.
1 Answer
It looks like you're trying to use the static method syntax, but methods like `LoadHtml` aren't static. That's why you don't get suggestions when using `[HtmlAgilityPack.HtmlDocument]::loadHt...`. You can check the static members by using `[HtmlAgilityPack.HtmlDocument] | Get-Member -static` to see what's available directly. Unfortunately, there isn’t a comprehensive documentation for the classes, but examples can be helpful. Just remember that you need to actually create an instance to access instance methods.
Aah, that is what it was.. I've been away, completely forgot about that, thank!