Created
October 12, 2012 12:17
-
-
Save clochix/3878938 to your computer and use it in GitHub Desktop.
Sample XPath to get node by it's content
This file contains hidden or 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
| // Get a node whose content starts with (optional spaces) "Doing" | |
| // Available functions : https://developer.mozilla.org/en-US/docs/XPath/Functions | |
| // (regex with matches are not available, XPath 2.0, only normalized still 2007 :S ) | |
| evaluation = document.evaluate("//*[starts-with(normalize-space(.), 'Doing')]", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue | |
| evaluation = document.evaluate("//h2[contains(., 'part')]", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment