Find all <a>s to who's href points to an image with XPath 1.0

Posted by Jeffrey Aylesworth on Stack Overflow See other posts from Stack Overflow or by Jeffrey Aylesworth
Published on 2010-03-17T16:09:31Z Indexed on 2010/03/17 16:11 UTC
Read the original article Hit count: 205

Filed under:
|
|
|

First, I can assume that all urls that end with jpeg, jpg, bmp, png or gif are images, and others aren't.

I thought of, and tried two solutions:

  • Matching the regular expression .(jpe?g|bmp|png|gif)$
  • Using ends-with to check each separately

But, it appears that neither of these exist in XPath 1.0, or at least, they don't exist in Firefox (I am writing a greasemonkey script, so it is only important for the path to work in Firefox).

© Stack Overflow or respective owner

Related posts about xpath

Related posts about JavaScript