10 January 2023

Get all nodes that have a defined attribute in xPath. Explanation of commands:

  • "//" selects nodes in the document from the current node that match the selection no matter where they are.
  • "*" is a wildcard, in our example it matches any element node.
  • "[]" square brackets symbolise that we are working with node properties.
  • "@" is a symbol that marks beginning of an attribute name.
Source code viewer
  1. //*[@data-my-attribute]
Programming Language: Text