Select-HtmlNode
August 3, 2026 ยท View on GitHub
SYNOPSIS
Selects HtmlAgilityPack nodes using XPath or common tag and attribute predicates.
SYNTAX
XPath (Default)
Select-HtmlNode [-InputObject] <Object> [-XPath] <string> [-Single] [<CommonParameters>]
Predicate
Select-HtmlNode [-InputObject] <Object> -Tag <string> [-AttributeName <string>] [-AttributeValue <string>] [-Contains] [-StartsWith] [-Text] [-Single] [<CommonParameters>]
DESCRIPTION
Selects HtmlAgilityPack nodes using XPath or common tag and attribute predicates.
EXAMPLES
EXAMPLE 1
ConvertFrom-Html -Content $html | Select-HtmlNode -XPath '//a'
EXAMPLE 2
ConvertFrom-Html -Content $html | Select-HtmlNode -Tag h3 -AttributeName class -AttributeValue 'title' -Single
PARAMETERS
-AttributeName
Attribute name used to build a simple XPath predicate.
Type: String
Parameter Sets: Predicate
Aliases: None
Possible values:
Required: False
Position: named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-AttributeValue
Attribute value used to build a simple XPath predicate.
Type: String
Parameter Sets: Predicate
Aliases: None
Possible values:
Required: False
Position: named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-Contains
Builds a contains() predicate for attribute matching.
Type: SwitchParameter
Parameter Sets: Predicate
Aliases: None
Possible values:
Required: False
Position: named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-InputObject
HtmlAgilityPack node, document, or raw HTML content to search.
Type: Object
Parameter Sets: XPath, Predicate
Aliases: None
Possible values:
Required: True
Position: 0
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
-Single
Returns only the first matching node.
Type: SwitchParameter
Parameter Sets: XPath, Predicate
Aliases: None
Possible values:
Required: False
Position: named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-StartsWith
Builds a starts-with() predicate for attribute matching.
Type: SwitchParameter
Parameter Sets: Predicate
Aliases: None
Possible values:
Required: False
Position: named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-Tag
Tag name used to build a simple XPath expression.
Type: String
Parameter Sets: Predicate
Aliases: None
Possible values:
Required: True
Position: named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-Text
Returns text nodes beneath the matching elements.
Type: SwitchParameter
Parameter Sets: Predicate
Aliases: None
Possible values:
Required: False
Position: named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-XPath
XPath expression passed to HtmlNode.SelectNodes or HtmlNode.SelectSingleNode.
Type: String
Parameter Sets: XPath
Aliases: None
Possible values:
Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
INPUTS
System.Object
OUTPUTS
HtmlAgilityPack.HtmlNode
RELATED LINKS
- None