Currently this command is limited to node arrays. See issue 18 for supporting other results to be printed.
Syntax
$x(xpath [, contextNode [, resultType]])
Parameters
XPath expression used to match the elements to return. This follows the syntax of document.evaluate(). (required)
contextNode
Element used as root node for the XPath expression. (optional; added in Firebug 1.11)
resultType
Object type returned by the function. (optional; added in Firebug 1.11)
resultType
Object type returned by the function. (optional; added in Firebug 1.11)Option | document.evaluate() equivalent | Description |
---|---|---|
"number" | XPathResult.NUMBER_TYPE | Numerical value |
"string" | XPathResult.STRING_TYPE | String value |
"bool" | XPathResult.BOOLEAN_TYPE | Boolean value |
"node" | XPathResult.FIRST_ORDERED_NODE_TYPE | Single HTML element |
"nodes" | XPathResult.UNORDERED_NODE_ITERATOR_TYPE | Array of HTML elements |
Examples
1. $x("//h1")
This returns an array of all
2. $x("//input[@type='checkbox']")
This returns an array of all checkboxes of a page.
3. $x("count(//h1)>5")
This checks whether there are more than five
s in the page and returns true or false. (requires Firebug 1.11 or higher)
4. $x("//p/b[1]/text()")
This returns an array of all text nodes within every first of all s of a page.
5. $x(".//button", $$("form")[1])
This returns an array of all within the second
of a page. (requires Firebug 1.11 or higher)
6. $x("//p", document, "node")
This returns the first inside the page. (requires Firebug 1.11 or higher)