You are here

public function Translator::cssToXPath in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/css-selector/XPath/Translator.php \Symfony\Component\CssSelector\XPath\Translator::cssToXPath()

Translates a CSS selector to an XPath expression.

Parameters

string $cssExpr:

string $prefix:

Return value

string

Overrides TranslatorInterface::cssToXPath

File

vendor/symfony/css-selector/XPath/Translator.php, line 121

Class

Translator
XPath expression translator interface.

Namespace

Symfony\Component\CssSelector\XPath

Code

public function cssToXPath($cssExpr, $prefix = 'descendant-or-self::') {
  $selectors = $this
    ->parseSelectors($cssExpr);

  /** @var SelectorNode $selector */
  foreach ($selectors as $index => $selector) {
    if (null !== $selector
      ->getPseudoElement()) {
      throw new ExpressionErrorException('Pseudo-elements are not supported.');
    }
    $selectors[$index] = $this
      ->selectorToXPath($selector, $prefix);
  }
  return implode(' | ', $selectors);
}