$x

From FirebugWiki

(Difference between revisions)
Jump to: navigation, search
(Separate Command Line API page for $x())
(Added description of syntax and linked back to Command Line API)
Line 2: Line 2:
Currently this command is limited to node arrays. See [http://code.google.com/p/fbug/issues/detail?id=18 issue 18] for supporting other [https://developer.mozilla.org/en/XPathResult results] to be printed.
Currently this command is limited to node arrays. See [http://code.google.com/p/fbug/issues/detail?id=18 issue 18] for supporting other [https://developer.mozilla.org/en/XPathResult results] to be printed.
 +
 +
== Syntax ==
 +
<source lang="javascript">
 +
$x(xpath)
 +
</source>
== Parameters ==
== Parameters ==
Line 29: Line 34:
== See also ==
== See also ==
* [https://developer.mozilla.org/en/Introduction_to_using_XPath_in_JavaScript Introduction to using XPath in JavaScript]
* [https://developer.mozilla.org/en/Introduction_to_using_XPath_in_JavaScript Introduction to using XPath in JavaScript]
 +
* [[Command Line API]]

Revision as of 10:46, 5 July 2012

This command returns an array of HTML or XML elements matching the given XPath expression. This means it is actually a shortcut for document.evaluate().

Currently this command is limited to node arrays. See issue 18 for supporting other results to be printed.

Contents

Syntax

$x(xpath)

Parameters

xpath

XPath expression used to match the elements to return. This follows the syntax of document.evaluate(). (required)

Examples

$x("//p")

This returns all <p>s of a page.

$x("//input[@type='checkbox']")

This returns all checkboxes of a page.

$x("//p/b[1]/text()")

This returns all text nodes within every first <b> of all <p>s of a page.

See also

Personal tools