W3cubDocs

/Symfony 2.7

Symfony\Component\CssSelector\CssSelector

class CssSelector

CssSelector is the main entry point of the component and can convert CSS selectors to XPath expressions.

$xpath = CssSelector::toXpath('h1.foo');

This component is a port of the Python cssselector library, which is copyright Ian Bicking, see https://github.com/SimonSapin/cssselect.

Methods

static string toXPath(mixed $cssExpr, string $prefix = 'descendant-or-self::')

Translates a CSS expression to its XPath equivalent.

static enableHtmlExtension()

Enables the HTML extension.

static disableHtmlExtension()

Disables the HTML extension.

Details

static public string toXPath(mixed $cssExpr, string $prefix = 'descendant-or-self::')

Translates a CSS expression to its XPath equivalent.

Optionally, a prefix can be added to the resulting XPath expression with the $prefix parameter.

Parameters

mixed $cssExpr The CSS expression.
string $prefix An optional prefix for the XPath expression.

Return Value

string

static public enableHtmlExtension()

Enables the HTML extension.

static public disableHtmlExtension()

Disables the HTML extension.

© 2004–2016 Fabien Potencier
Licensed under the MIT License.
http://api.symfony.com/2.7/Symfony/Component/CssSelector/CssSelector.html