Syntax
- Inside a specific node
- /path to/element[@attribute_name]
- Anywhere in the document
- Inside a specific node with some value
- /path to/element[@attribute_name='search value']
- /path to/element[@attribute_name="search value"]
- Anywhere in the document with some value
- //*[@attribute_name='search string']
- //*[@attribute_name="search string"]
Parameters
Selector | function |
---|
@attribute_name | It selects the attribute value for a node, if present |
Using [@attribute_name] we can select nodes that have the attribute irrespective of the value.
We can use any of the functions or combination of the functions such as starts-with and lowercase, for example, with this selector to suit our needs.