[Greasemonkey] generating XPath string from dom node
Johan Sundström
oyasumi at gmail.com
Sat Mar 18 16:28:45 EST 2006
On 3/16/06, Jonathan Buchanan <jonathan.buchanan at gmail.com> wrote:
> Since we're going right to the root, I suppose the double forward
> slash could be omitted as well?
Yes. And I would further suggest stopping at the first ancestor node
(counting from the target node) with an id attribute, making for an
xpath like //something[@id="something"]/rest/of/path. This generally
improves the quality / longevity of the match, as page structure
changes over time, since it doesn't matter if the beginning of the
page grows additional content, changing the beginning of the xpath
signature of the target node.
--
/ Johan Sundström, http://ecmanaut.blogspot.com/
More information about the Greasemonkey
mailing list