[Greasemonkey] Re: Mechanical Turk Script to Auto Accept

Jeremy Dunck jdunck at gmail.com
Thu Nov 10 16:08:49 EST 2005


On 11/10/05, blakewest (sent by Nabble.com) <lists at nabble.com> wrote:
>
> I wrote a script to do this same thing, but I don't understand the whole xpath thing, so I used document.getElementsByTagName('a') and then ran a RegExp against the collection.
>
> My approach also works, but is xpath better for some reason?

XPath is to DOM traversal what SQL is to relational terversal. 
(Kinda. There's also XQuery...)  It's just a domain-specific language
so that you don't have to have complex DOM manipulation for something
you can accomplish in a single expression.

>Does anyone know a good tutorial on using xpath to locate elements?

I don't really know XPath; I've just learned enough to be dangerous.

This is the one I use:
http://www.zvon.org/xxl/XPathTutorial/General/examples.html

Aesthetically the pages suck, but they're very useful.

I've never used XPath in webdev before GM, mostly because it's not
well supported in other browsers.


More information about the Greasemonkey mailing list