I am writing powershell script that reads HTML from rich text field and then updates it. I am trying to use HtmlAgilityPack to read html.

To test HtmlAgilityPack I wrote short script (below), which runs successfully (loads html and prints it to screen) in Powershell ISE, but does not load html when run in Sitecore powershell editor.

Any ideas what I am missing?

$html = "<p>Testing</p>"
Add-Type -path "C:\HtmlAgilityPack\HtmlAgilityPack.dll"
$doc = New-Object HtmlAgilityPack.HtmlDocument
Write-Host "Text:" $doc.Text

1 Answer 1


Try this :

$html = "<p>Testing</p>"
$doc = New-Object -TypeName HtmlAgilityPack.HtmlDocument
Write-Host "Text:" $doc.DocumentNode.SelectNodes("//p")[0].InnerHtml


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.