AttributeMatchingExtension example

private array $attributeMatchingTranslators = [];

    public function __construct(ParserInterface $parser = null)
    {
        $this->mainParser = $parser ?? new Parser();

        $this
            ->registerExtension(new Extension\NodeExtension())
            ->registerExtension(new Extension\CombinationExtension())
            ->registerExtension(new Extension\FunctionExtension())
            ->registerExtension(new Extension\PseudoClassExtension())
            ->registerExtension(new Extension\AttributeMatchingExtension())
        ;
    }

    public static function getXpathLiteral(string $element): string
    {
        if (!str_contains($element, "'")) {
            return "'".$element."'";
        }

        if (!str_contains($element, '"')) {
            return '"'.$element.'"';
        }
Home | Imprint | This part of the site doesn't use cookies.