Created
August 2, 2012 21:37
-
-
Save cstorey/3240877 to your computer and use it in GitHub Desktop.
Run an xpath expression against the current document
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function nice_xpath(xp) { | |
var x = document.evaluate(xp, document.documentElement, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null, null); | |
if (x) { | |
var node = x.iterateNext(); | |
while (node) { | |
console.log(node); | |
node = x.iterateNext(); | |
} | |
} | |
} | |
var xp = ".//*[self::input | self::textarea][(./@id = //label[contains(normalize-space(string(.)), user_password)]/@for)]"; | |
nice_xpath(xp); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment