[Xpath] domxpath query and return value .......

liunx

Guest
Hi.
I've got this simple method:

public function select($item,$value){
$xp= new domxpath($this->doc);
$query= "/users/user[{$item}/text()='{$value}']";
$user= $xp->query($query);
var_dump($user instanceof DOMNodeList);
var_dump(is_null($user));
var_dump(isset($user));
}

It works fine if there is a macth
but guest you it doesn't work if
there isn't one :confused:
Could you explain me why ?
How can I do to check if there isn't a match ?
Thanks in advance.

Bye.Sorry it works I made a mistake
in a other part of the script :eek:

public function select($item,$value){
$xp= new domxpath($this->doc);
$query= "/users/user[{$item}/text()='{$value}']";
$user= $xp->query($query);
return (bool)count($user);
}

Bye.
 
Top