[Greasemonkey] XPath n00b help

Roderick McGuire mcguire at telerama.com
Sat Feb 11 21:20:50 EST 2006

Mitchell Mebane wrote:

You should consider installing the XPather extension:

It makes trying out XPATHS easy

> Hi there, ...

> The info is stored in blocks like so:
> <span class="galheader">
>    <strong>Item:</strong> MG-SP40<br>
>    <strong>Image count:</strong> 24<br>
> </span>
> I've tried
> //strong[text()='Item'][following-sibling::text()]
> but I think I'm not understanding the syntax. How would I go about this?

First off, I believe text selects a text node. It isn't a function that 
returns the text of a node. so for the first part you want:

  //strong/text()[., contains('Item:')]

I would make the search a little more constrained by as:

  //span [@class='galheader']/strong/text()[., contains('Item:')]

But I don't understand why you are doing that. Actually what you want is 
the text node under a galheader preceded by a strong image count.

I would write that as:


I've had proroblems with the various axis declarations in XPATH and I'm 
not sure which of them are actually implemented in Firefox.

More information about the Greasemonkey mailing list