XPath queries select nodes from an HTML document after ConvertFrom-Html turns a web response into a navigable object. They make web scraping practical when the needed data is buried in search results or detail pages rather than exposed by a public backend. section 13.3 section 13.3.1
Start from the browser’s inspected element, but do not rely on a copied XPath whose id changes for every result. Compare equivalent elements and build a query from attributes that remain shared, such as class and href. Pass that query to SelectNodes to return every matching link; use SelectSingleNode when one identified detail-page field is required. section 13.3.1
$xPath = '//*[' +
'@class="contentTextItemSpacerNoBreakLink" ' +
'and @href="javascript:void(0);"]'
$Search.SelectNodes($xPath) | Format-Table NodeType, Name, Id, InnerText
NodeType Name AttributeCount ChildNodeCount ContentLength InnerText
-------- ---- -------------- -------------- ------------- ---------
Element a 4 1 144 ...
Element a 4 1 148 ...
Element a 4 1 148 ...
This query matches result links by their shared class and href instead of a result-specific id, returning all matching elements for later processing. section 13.3.1
A repeatable scraping flow is:
- Build a search URL and convert its HTML response into a document object. section 13.3.1
- Select matching result links with XPath, then extract and normalize each link id. section 13.3.1
- Request each detail page and select fields such as architecture, supported products, or supersedence information. section 13.3.1
- Traverse selected child elements when the desired values are nested, then turn the results into structured objects. section 13.3.1
Finding update supersedence
For a KB search with multiple results, select all result anchors by shared attributes, remove the _link suffix from each id, and use the resulting id to request its detail page. A node selected by supersededbyInfo can then be traversed through div and a elements to collect superseding KB titles and identifiers. section 13.3.1


