This project has moved. For the latest updates, please go here.

Unable to load html

Topics: Developer Forum, User Forum
Apr 1, 2012 at 11:05 PM

I'm trying to use the HTML Agility pack and PowerShell to get data from web-sites. The problem is that after I try to load the html through HtmlDocument.LoadHtml () or HtmlDocument.Load(filename) , the result is null. Here's a very simple example showing the problem:

$htmlstring = @'
		<title>The new way</title>
	</head> <body>
This is a  test 
add-type -Path E:\prof\computing\Web\HtmlAgilityPack.1.4.0\HtmlAgilityPack.dll 
$doc = New-Object HtmlAgilityPack.HtmlDocument 
$result = $doc.LoadHtml($htmlstring) 
if ($result -eq $null) {"null returned"}else{"non-null return"}
This results in the message "null returned".

 I thought I had this working but even my test data html files aren't loading now.

I've been using PowerGui (now v3.2) for most of my development but the example produces exactly the same results when run on PowerShell ISI.


Any ideas?