Specifying Attributes in Queries
To specify an attribute name in a query, precede the attribute name with an at sign (@). The XPath processor treats elements and attributes in the same way wherever possible. For example:
This query returns the
Following is another query that includes an attribute:
This query returns the three
The following query returns the
If the context node does not have a
The next query returns the
Following is an example that is not valid because attributes cannot have subelements:
Following is a query that finds the
Attributes cannot contain subelements. Consequently, you cannot apply a path operator to an attribute. If you try to, you receive a syntax error.
Attributes are inherently unordered. Consequently, you cannot apply a position number to an attribute. If you try to, you receive a syntax error.
Attributes and Wildcards
You can use an at sign (@) and asterisk (*) together to retrieve a collection of attributes. For example, the following query finds all attributes in the current context: