Skip to content

Commit 5387c06

Browse files
authored
Merge pull request #1695 from scriptingstudio/master
[Get-HtmlTable] XPath optimization
2 parents fa447a7 + 45ed6a0 commit 5387c06

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

Public/Get-HtmlTable.ps1

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ function Get-HtmlTable {
5050
else {
5151
$h = ConvertFrom-Html -Content $r.Content
5252
if ($TableIndex -is [valuetype]) { $TableIndex += 1}
53-
$rows = $h.SelectNodes("//table[$TableIndex]//tr")
53+
$rows = try {
54+
$h.SelectSingleNode("//table[$TableIndex]").SelectNodes(".//tr")
55+
} catch {}
5456
if (-not $rows) {Write-Warning "Could not find rows for `"//table[$TableIndex]`" in $Url ."}
5557
if ( -not $propertyNames) {
5658
if ( $tableHeaders = $rows[$FirstDataRow].SelectNodes("th")) {

0 commit comments

Comments
 (0)