domxpath->query: bug or not?

From: Date: Wed, 18 Feb 2004 22:09:07 +0000
Subject: domxpath->query: bug or not?
Groups: php.internals 
Request: Send a blank email to internals+get-7976@lists.php.net to get a copy of this message
Hi, If I know well, the domxpath::query always returns with DOMNodeList. But if i write an expression like this: //node1/@attribute and i haven't got node1 node in the XML, the query return with false (boolean). But if i write an expression like this: //node1/@attr when i have node1 node but i haven't got attr attribute on that, the query return with an empty DOMNodeList. Here is a sample code: $doc = new DOMDocument(); $doc -> loadXML('<xml><node1 name="x"/></xml>'); $xp = new DOMXPath($doc); print "Expression1:\n"; var_dump( $xp -> query("//node1/@attr")); print "\nExpression2:\n"; var_dump( $xp -> query("//node2/@attr")); And the result: Expression1: object(domnodelist)#3 (0) { } Expression2: bool(false) If it's not a bug, please inform me about the details. Thanks: zsolt banyai zsolt.banyai@kirowski.com

« previous php.internals (#7976) next »