protected function quoteXpathAttribute(string $input): string
    {
        if (mb_strpos($input, '\'') === false) { // Selector does not contain single quotes
            return "'$input'"; // Encapsulate with double quotes
        }

        if (mb_strpos($input, '"') === false) { // Selector contain single quotes but not double quotes
            return "\"$input\""; // Encapsulate with single quotes
        }

        // When both single and double quotes are contained, escape each part individually and concat() all parts
        return "concat('" . strtr($input, ['\'' => '\', "\'", \'']) . "')";
    }
protected function quoteXpathAttribute(string $input): string
    {
        if (mb_strpos($input, '\'') === false) { // Selector does not contain single quotes
            return "'$input'"; // Encapsulate with double quotes
        }

        if (mb_strpos($input, '"') === false) { // Selector contain single quotes but not double quotes
            return "\"$input\""; // Encapsulate with single quotes
        }

        // When both single and double quotes are contained, escape each part individually and concat() all parts
        return "concat('" . strtr($input, ['\'' => '\', "\'", \'']) . "')";
    }
protected function quoteXpathAttribute ( string $ input ) : string { if ( mb_strpos ( $ input , '\'' ) === false ) { // Selector does not contain single quotes return "'$input'" ; // Encapsulate with double quotes } if ( mb_strpos ( $ input , '"' ) === false ) { // Selector contain single quotes but not double quotes return "\"$input\"" ; // Encapsulate with single quotes } // When both single and double quotes are contained, escape each part individually and concat() all parts return "concat('" . strtr ( $ input , [ '\'' => '\', "\'", \'' ] ) . "')" ; }
Encapsulate given attribute value into valid xpath expression.

@param string $input Value of an xpath attribute selector
Encapsulate given attribute value into valid xpath expression .