XPath queries in Google Chrome console XPath queries in Google Chrome console google-chrome google-chrome

XPath queries in Google Chrome console


Evaluating $x returns ...

function $x(xpath, [startNode]) { [Command Line API] }

So, the syntax is $x('my/path', a).

Important is that, $x returns an array but startNoderequires a DOM node, so you have to take an element of the first query. The following sample demonstrates the behavior on the current page.

a = $x("//*[@id='question-header']")> [ <div id=​"question-header">​…​</div>​ ]b = $x(".//*[@href]/text()", a[0])> [ "XPath queries in Google Chrome console" ]

Update: Here is the documentation.