[Greasemonkey] Parsing whole pages by regex
Aaron Boodman
zboogs at gmail.com
Sun May 28 08:29:09 EDT 2006
On 5/27/06, John Horner <john.horner at gmail.com> wrote:
> what's the
> easiest way for me to find the right JavaScript reference to the
> third nested table inside the second nested table inside the fourth
> <CENTER> tag (not actually the address)?
You can use xpath to do queries just like this. For this, it'd be
something like:
//center[4]//table[2]//table[3]
You can see more details here:
http://diveintogreasemonkey.org/patterns/match-attribute.html
http://www.w3.org/TR/DOM-Level-3-XPath/xpath.html#XPathEvaluator-evaluate
Since you only want one element, you might change the example query to:
var table = document.evaluate(
'//center[4]//table[2]//table[3]',
document,
null,
XPathResult.FIRST_ORDERED_NODE_TYPE,
null).singleNodeValue;
You'll have to play with the expression a bit to get what you want.
Here is a tutorial on xpath syntax:
http://www.zvon.org/xxl/XPathTutorial/General/examples.html
Hope this helps.
- a
More information about the Greasemonkey
mailing list