Predicates are filters that restrict the nodes selected by an XPath expression. Predicates appear inside [square brackets].
Courses
/courses/course[@acad_year = 2009][@offered = 'Y']
/courses/course[@acad_year = 2009 and @offered = 'Y']
Congress
/congress/person[role/@type = 'sen']
/congress/person[role/@state = 'CA']
RSS
/rss/channel/item[position() = 1]
/rss/channel/item[position() = last()]
/rss/channel/item[position() mod 2 = 0]
/rss/channel/item[position() mod 2 = 0]/title
/rss/channel/item[1]/title
XHTML
/html/head/title
/html/body//a[@href]
What is the difference between the following?
/html/body//a[@href]
/html/body//a/@href