Class

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 lxml library, which is copyright Infrae and distributed under the BSD license.

Methods

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

Translates a CSS expression to its XPath equivalent.

NodeInterface parse(string $string)

Parses an expression and returns the Node object that represents the parsed expression.

Details

at line 45
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

Exceptions

ParseException When got None for xpath expression

at line 93
public NodeInterface parse(string $string)

Parses an expression and returns the Node object that represents the parsed expression.

Parameters

string $string The expression to parse

Return Value

NodeInterface

Exceptions

Exception When tokenizer throws it while parsing