How do I select elements that have two attributes?
I can do
@name | @area
which is "name or area", but how do I do "name and area"?
How do I select elements that have two attributes?
I can do
@name | @area
which is "name or area", but how do I do "name and area"?
Well, don't use @name | @area
- it's not 'or', it's a join which happens to work incidentally.
For 'or', do foo[@name or @area]
.
For 'and', do foo[@name and @area]
.
XPath does provide you with an and
operator which can be used to evaluate multiple conditions using predicates:
Possibles:
//MyElement[@name][@area]
//MyElement[@name and @area]