Ultimate companion for HTML parsing using XPath selectors. This cheatsheet contains all syntax explanations with interactive examples.
XPath allows interacting with any element's attribute such as
href and any other through the
@ syntax. This means we can select any element in the HTML DOM based on its attribute value with XPath.
To find elements by attribute value, the name of the attribute can be used in
[@attribute=value] predicate syntax or using
contains() function for a partial match like so:
Here are some interactive examples to demonstrate this: