Re: PHP 5: SimpleXML attributes
| From: | Dan Phiffer | Date: | Wed, 07 Apr 2004 20:48:01 +0000 |
| Subject: | Re: PHP 5: SimpleXML attributes | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-182705@lists.php.net to get a copy of this message | ||
John W. Holmes wrote:
Have you seen Example 4 here: http://us2.php.net/manual/en/ref.simplexml.php Not sure if that helps or not, though, but it looks like it's already an associative array.It certainly looks like an associative array, but the array_keys() function chokes on it: Warning: array_keys() [function.array-keys]: The first argument should be an array in D:\...\test.php on line 5 Explicitely casting it as an array doesn't work either. I guess I want something like example 4, but without having to hardcode in the $rating['type']. Something more like: foreach ($xml->movie[0]->rating as $rating) {
foreach ($rating->attributes() as $key => $value) {
if ($key == 'type') {
switch ($rating['type']) {
...
}
}
}
}
Thanks,
-Dan