#34413 [Bgs]: DOMXPath->query() ignores context nodes

From: Date: Thu, 08 Sep 2005 06:48:37 +0000
Subject: #34413 [Bgs]: DOMXPath->query() ignores context nodes
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-84683@lists.php.net to get a copy of this message
ID: 34413 Updated by: chregu@php.net Reported By: thisisroot at gmail dot com Status: Bogus Bug Type: XML related Operating System: Mac OS 10.4.2 PHP Version: 5.0.5 New Comment: btw, this: echo $key->nodeValue . "\n"; is wrong. too. You need to loop through the DomNodeList you get from query() with foreach... Previous Comments: ------------------------------------------------------------------------ [2005-09-08 08:46:23] chregu@php.net your xpath query is not relative. Use $key = $xpath->query( './/key', $node); and it works And please provide a really self runnning example next time, we're mostly not in the mood to make your examples running on our computers.. ------------------------------------------------------------------------ [2005-09-07 23:44:36] sniper@php.net Please try using this CVS snapshot: http://snaps.php.net/php5-latest.tar.gz For Windows: http://snaps.php.net/win32/php5-win32-latest.zip ------------------------------------------------------------------------ [2005-09-07 22:07:24] thisisroot at gmail dot com Description: ------------ DOMXPath->query() seems to totally ignore context nodes. I get an empty DOMNodeList when I execute a query with a context node. P.S.: Your bug submission process is a real PITA. Could we have just one CAPTCHA, please? Reproduce code: --------------- // I just deleted the real code, but here's a sample // Assume the document and xpath parser have already been // instantiated. /* $doc = <kvps> <string> <key>My Key</key> <value>My Value</value> <string> </kvps> */ $nodes = $xpath->query( '//string'); foreach ( $nodes as $node) { print_r( $node); $key = $xpath->query( '//key', $node); echo $key->nodeValue . "\n"; print_r( $key); } Expected result: ---------------- I expect $key to be the DOMElement tagged as "key" inside of the current "string" element. Actual result: -------------- An empty NodeList ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=34413&edit=1

« previous php.bugs (#84683) next »