Skip to content

Instantly share code, notes, and snippets.

@lingo
Created August 10, 2010 08:16
Show Gist options
  • Save lingo/516904 to your computer and use it in GitHub Desktop.
Save lingo/516904 to your computer and use it in GitHub Desktop.
XPath hasClass
# Based on code here: http://westhoffswelt.de/blog/0036_xpath_to_select_html_by_class.html
$x('//a[@class
and (
contains(normalize-space(@class), " q ")
or starts-with(normalize-space(@class), "q ")
or substring(normalize-space(@class), string-length(normalize-space(@class)) - string-length("q")) = " q"
or @class = "q"
)
]')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment