note 73044 added to function.xml-parse-into-struct
| From: | siteres at gmail dot com | Date: | Wed, 07 Feb 2007 09:38:39 +0000 |
| Subject: | note 73044 added to function.xml-parse-into-struct | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-123035@lists.php.net to get a copy of this message | ||
PHP: XML to Array and backwards:
Here the XML with PHP solution: XML->Array and Array->XML.
Work with it as with usual array.
Sources are here:
http://mysrc.blogspot.com/2007/02/php-xml-to-array-and-backwards.html
(leave me comments:)
Example #1 (1.xml):
<ddd>
<onemore dd="55">
<tt>333</tt>
<tt ss="s1">555</tt>
<tt>777</tt>
</onemore>
<two>sdf rr</two>
</ddd>
The code:
$xml=xml2ary(file_get_contents('1.xml'));
print_r($xml);
Here is the Array result:
Array
(
[ddd] => Array (
[_c] => Array (
[_p] => Array *RECURSION*
[onemore] => Array (
[_a] => Array (
[dd] => 55
)
[_c] => Array (
[_p] => Array *RECURSION*
[tt] => Array (
[0] => Array (
[_v] => 333
)
[1] => Array (
[_a] => Array (
[ss] => s1
)
[_v] => 555
)
[2] => Array (
[_v] => 777
)
)
)
)
[two] => Array (
[_v] => sdf rr
)
)
)
)
----
Server IP: 69.147.83.197
Probable Submitter: 88.214.196.107
----
Manual Page -- http://www.php.net/manual/en/function.xml-parse-into-struct.php
Edit -- https://master.php.net/note/edit/73044
Del: integrated -- https://master.php.net/note/delete/73044/integrated
Del: useless -- https://master.php.net/note/delete/73044/useless
Del: bad code -- https://master.php.net/note/delete/73044/bad+code
Del: spam -- https://master.php.net/note/delete/73044/spam
Del: non-english -- https://master.php.net/note/delete/73044/non-english
Del: in docs -- https://master.php.net/note/delete/73044/in+docs
Del: other reasons-- https://master.php.net/note/delete/73044
Reject -- https://master.php.net/note/reject/73044
Search -- https://master.php.net/manage/user-notes.php