02b: XPATH Practice Flashcards
Expression:
All title elements that are grandchildren of bookstore elements
bookstore/*/title
Expression:
All book elements with style attributes of the current context
book[@style]
Expression:
The style attribute for all book elements of the current context
book/@style
Expression:
All attributes of the current element context
@*
Expression:
All first-name elements in the current context node
./first-name
Expression:
The third author element that has a first-name child
author[first-name][3]
Expression:
All author elements that contain at least one degree element child and at least one award element child
author[degree and award]
Expression:
All author elements that contain at least one degree or award and at least one publication as the children
author[(degree or award) and publication]
Expression:
All author elements where the first last-name child element has the value “Bob”
author[last-name[1] = “Bob”]
Expression:
The author elements whose value is “Matthew Bob”
author[. = “Matthew Bob”]
Expression:
All author elements that contain a last-name child element whose value is “Bob”, and a price sibling element whose value is greater than 50
author[last-name = “Bob” and ../price > 50]
Expression:
All author elements containing any child element whose value is “Bob”
author[* = “Bob”]
Expression:
All author elements that has a last-name child element with the value “Bob” and a first-name child element with the value “Joe”
author[last-name = “Bob” and first-name = “Joe”]
Expression:
The nearest book ancestor of the context node
ancestor::book[1]
Expression:
Select all author elements that contain a first-name child element whose value is “Alex” and a price sibling element whose value is less than 20
author[first-name = “Alex” and ../price < 20]