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')";
    }
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')";
    }
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')" ; }
Quote the given value for an xpath expression

This will also automatically enclose the string

@param string $string
@return string
Quote the given value for an xpath expression