public static function quoteXpathValue($string)
    {
        if (strpos($string, "'") === false) {
            return "'$string'";
        }

        if (strpos($string, '"') === false) {
            return '"' . $string . '"';
        }

        // String contains ' and " -> need to use concat ...
        $parts = explode("'", $string);
        $quoted = implode('\', "\'", \'', $parts);

        return "concat('$quoted')";
    }