Code snippets
From GreaseSpot Wiki
xpath helper
function xpath(p, context) { if (!context) context=document; var arr=[]; var xpr=document.evaluate( p, context, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null ); for(i=0;item=xpr.snapshotItem(i);i++){ arr.push(item); } return arr; }
Run a particular xpath expression p
against the context node context
(or the document, if not provided).
Return the results as an array.