note 103289 added to book.simplexml
| From: | info at jeremycarlson dot com | Date: | Tue, 05 Apr 2011 22:48:09 +0000 |
| Subject: | note 103289 added to book.simplexml | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-178534@lists.php.net to get a copy of this message | ||
@Marcus (http://us2.php.net/manual/en/book.simplexml.php#103173) -
I tried your code.
Given your arrogant tone, I expected it to work well. For me, it does not.
I am *NOT* a developer qualified to fix your script, but I found the following.
With this XML file run through your xml2array function:
<?xml version="1.0" encoding="UTF-8"?>
<events_get_response>
<event>
<name>Event One</name>
</event>
<event>
<name>Event Two</name>
</event>
<event>
<name>Event Three</name>
</event>
</events_get_response>
I got the following array on my machine running PHP 5.2.11:
Array
(
[event] => Array
(
[value] => Array
(
[name] => Array
(
[value] => Event One
[attributes] => Array
(
)
)
[0] => Array
(
[name] => Array
(
[value] => Event Two
[attributes] => Array
(
)
)
)
[1] => Array
(
[name] => Array
(
[value] => Event Three
[attributes] => Array
(
)
)
)
)
[attributes] => Array
(
[0] => Array
(
)
[1] => Array
(
)
)
)
)
Events #2 & #3 are not at the same level as Event #1.
To access the name for event #1, I'd point to
$array['event']['value']['name']['value'];
To access the name for event #2, I'd point to
$array['event']['value'][0]['name']['value'];
That may be useful for you somehow, but it's certainly not what I would expect, nor what I
need.
----
Server IP: 64.71.164.2
Probable Submitter: 184.96.165.39
----
Manual Page -- http://www.php.net/manual/en/book.simplexml.php
Edit -- https://master.php.net/note/edit/103289
Del: integrated -- https://master.php.net/note/delete/103289/integrated
Del: useless -- https://master.php.net/note/delete/103289/useless
Del: bad code -- https://master.php.net/note/delete/103289/bad+code
Del: spam -- https://master.php.net/note/delete/103289/spam
Del: non-english -- https://master.php.net/note/delete/103289/non-english
Del: in docs -- https://master.php.net/note/delete/103289/in+docs
Del: other reasons-- https://master.php.net/note/delete/103289
Reject -- https://master.php.net/note/reject/103289
Search -- https://master.php.net/manage/user-notes.php