Example from www.php.net
| From: | Timothy Murphy | Date: | Mon, 02 Apr 2007 10:45:48 +0000 |
| Subject: | Example from www.php.net | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-251912@lists.php.net to get a copy of this message | ||
I was trying Example 2147, which reads:
-------------------------------
<?php
$string = <<<XML
<a xmlns:b>
<foo name="one" game="lonely">1</foo>
</a>
XML;
$xml = simplexml_load_string($string);
foreach($xml->foo[0]->attributes() as $a => $b) {
echo $a,'="',$b,"\"\n";
}
?>
-------------------------------
It says that 'The above example will output:
name="one"
game="lonely"'
However, in my case it outputs nothing.
(I'm running php-5.1.6 under Fedora-6.)
Is there an error in the example;
or is the error mine?
--
Timothy Murphy
e-mail (<80k only): tim /at/ birdsnest.maths.tcd.ie
tel: +353-86-2336090, +353-1-2842366
s-mail: School of Mathematics, Trinity College, Dublin 2, Ireland