0

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
$doc.LoadHtml($html)
Write-Host "Text:" $doc.Text

1 Answer 1

1

Try this :

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

-Hetal

Your Answer

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

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