PHP.GT

Pseudo selectors

Pseudo selectors

A focused set of pseudo selectors is currently supported.

Boolean attribute pseudo selectors

These map directly to attribute presence checks:

  • :checked
  • :disabled
  • :selected

Example:

input:checked

Structural pseudo selectors

  • :first-child
  • :nth-child(n)
  • :last-child
  • :first-of-type
  • :nth-of-type(n)
  • :last-of-type

Example:

form label:nth-of-type(2) input

Other supported pseudo selectors

  • :text maps to [@type="text"] (useful for form inputs).
  • :contains('Example') maps to a text contains check.

Limitations

Only the pseudo selectors listed above are implemented. If we use an unsupported pseudo selector, it is not translated into an XPath predicate.


Work with different document types with HTML mode and XML mode.