Home
Paste
XPath Test in Browser Console
(listed)
11.01.2023 11:41:04
(17 lines)
[Edit]
[Raw]
[MD]
//just a quick function for copy/pasting into the console function xpath(path, root) { return document.evaluate(path, root || document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; } //more js-styled functions function getElementsByXPath(xpath, parent) { let results = []; let query = document.evaluate(xpath, parent || document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); for (let i = 0, length = query.snapshotLength; i < length; ++i) { results.push(query.snapshotItem(i)); } return results; } function getElementByXPath(path, root) { return document.evaluate(path, root || document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; }
1
2
//just a quick function for copy/pasting into the console
function
xpath
(
path
,
root
)
{
return
document
.
evaluate
(
path
,
root
||
document
,
null
,
XPathResult
.
FIRST_ORDERED_NODE_TYPE
,
null
)
.
singleNodeValue
;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
⇱
▲
⨀
▼
⤋
Plain Text
Markdown
XML
HTML
PHP
Java Script
CSS
JSON
C++
C#
Java
Kotlin
SQL
PostgreSQL
Pascal
Batch
Bash (SH)
PowerShell
Lua
Python
G-Code
//just a quick function for copy/pasting into the console function xpath(path, root) { return document.evaluate(path, root || document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; } //more js-styled functions function getElementsByXPath(xpath, parent) { let results = []; let query = document.evaluate(xpath, parent || document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); for (let i = 0, length = query.snapshotLength; i < length; ++i) { results.push(query.snapshotItem(i)); } return results; } function getElementByXPath(path, root) { return document.evaluate(path, root || document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; }