note 58199 modified in function.simplexml-element-children by danbrown

From: Date: Wed, 16 Sep 2009 15:34:45 +0000
Subject: note 58199 modified in function.simplexml-element-children by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-160639@lists.php.net to get a copy of this message
Just a quick addition: If you need to access a child node which contains a dash, you need to encapsulate it with {""}. For example: <?php foreach ($domain->domain-listing as $product) { } ?> The example above doesn't work because of the dash. But instead you need to use: <?php foreach ($domain->{"domain-listing"} as $product) { } ?> At least for me the second example works perfectly fine. --was-- Just a quick addition: If you need to access a child node which contains a dash, you need to encapsulate it with {""}. For example: <?php foreach ($domain->domain-listing as $product) { } ?> The example above doesn't work because of the dash. But instead you need to use: <?php foreach ($domain->{"domain-listing"} as $product) { } ?> At least for me the second example works perfectly fine. http://php.net/manual/en/function.simplexml-element-children.php

« previous php.notes (#160639) next »