note 88232 modified in function.simplexml-element-registerXPathNamespace by danbrown

From: Date: Wed, 16 Sep 2009 15:57:07 +0000
Subject: note 88232 modified in function.simplexml-element-registerXPathNamespace by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-160702@lists.php.net to get a copy of this message
Registering xpath-namespaces is mandatory when your input xml has a default namespace. Unfortunately an empty prefix '' cannot be registered, I use 'default' as prefix: <?php $sxe->registerXPathNamespace('default', 'mynamespace'); // then $sxe->xpath('//default:nodename'); ?> Bad news is that xpath-namespaces must be registered on EVERY SimpleXMLElement on which ->xpath() is to be called! (registering it on root node is not sufficient) --was-- Registering xpath-namespaces is mandatory when your input xml has a default namespace. Unfortunately an empty prefix '' cannot be registered, I use 'default' as prefix: <?php $sxe->registerXPathNamespace('default', 'mynamespace'); // then $sxe->xpath('//default:nodename'); ?> Bad news is that xpath-namespaces must be registered on EVERY SimpleXMLElement on which ->xpath() is to be called! (registering it on root node is not sufficient) http://php.net/manual/en/function.simplexml-element-registerXPathNamespace.php

« previous php.notes (#160702) next »