Ultimate companion for HTML parsing using XPath selectors. This cheatsheet contains all syntax explanations with interactive examples.
To select sibling elements in XPath the
following-sibling axes can be used - see these interactive examples:
preceding-sibling::spanwill select any siblings that precede (i.e. are above) the current element:
following-sibling::spanwill select siblings that follow (i.e. are below) the current element:
Note that the wildcard character can be used instead of explicit element names (e.g.
following-sibling::*) to select siblings of any element name.
For more on XPath, see our full introduction article