[Greasemonkey] generating XPath string from dom node
Matt Labrum
darktempler at gmail.com
Thu Mar 16 19:57:17 EST 2006
function createxPath(e){
var nodes = Array(e.tagName);
parent = e.parentNode;
while(parent){
nodes[nodes.length] = parent.tagName;
parent = parent.parentNode;
}
nodes = nodes.reverse();
var xpath = '//';
for(var i=0;i<nodes .length;i++){
if(typeof(nodes[i])=='undefined')continue;
xpath += nodes[i] + '/';
}
xpath = xpath.substr(0,xpath.length-1);
return xpath;
}
On 3/16/06, Al <anevare1 at yahoo.com> wrote:
>
> Is there a simple technique for obtaining the XPath expression for a
> clicked-on html dom node? Something similar to the way Platypus creates an
> XPath to a right-clicked element when it stores a user script. Thanks for
> your suggestions. Al
>
>
> _______________________________________________
> Greasemonkey mailing list
> Greasemonkey at mozdev.org
> http://mozdev.org/mailman/listinfo/greasemonkey
>
More information about the Greasemonkey
mailing list