note 45863 deleted from function.dom-domxpath-registernamespace by tomsommer

From: Date: Wed, 22 Sep 2004 19:33:30 +0000
Subject: note 45863 deleted from function.dom-domxpath-registernamespace by tomsommer
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-77204@lists.php.net to get a copy of this message
Note Submitter: gem at rellim dot com ---- Here is a working code sample: $s =<<<EOT <rootname xmlns="http://www.some.org/" xml:lang="en-US"> <childnode>Some text</childnode> </rootname> EOT; $xml = DOMDocument::loadXML( $s); $objectXPath = new DOMXPath($xml); # this returns nothing $NodeList = $objectXPath->query("/rootname/childnode"); echo "Length /rootname/childnode {$NodeList->length}<br>\n"; $objectXPath->registerNamespace( 'pre', "http://www.some.org/"); # this returns what you expect $NodeList = $objectXPath->query("/pre:rootname/pre:childnode"); echo "Length /pre:rootname/pre:childnode {$NodeList->length}<br>\n"; Run it and you get: Length /rootname/childnode 0 Length /pre:rootname/pre:childnode 1

« previous php.notes (#77204) next »