[Typo3-dev] t3lib_div::xml2array() and collections
Jerome
typo3dev at ameos.com
Tue Dec 13 20:05:59 CET 2005
Hello,
I'm using an XML file in my extension.
I use t3lib_div::xml2array() to get an array containing the structure of the
XML.
But I have a problem : the function gets rid of my collections.
Ex:
----------------------------------
$xml = "<root>
<sometag>hello</sometag>
<items>
<item>first item</item>
<item>second item</item>
<item>third item</item>
</items>
</root>";
print_r(t3lib_div::xml2array($xml));
----------------------------------
==> prints :
Array
(
[sometag] => hello
[items] => Array
(
[item] => third item
)
)
while I was expecting something like this ( maybe I'm wrong )
Array
(
[sometag] => hello
[items] => Array
(
[0] => first item
[1] => second item
[2] => third item
)
)
but then I get no information about the name of the tag ( item )
Or maybe something like macmade did in tx_apimacmade::div_xml2array() ( I
don't talk here about the root tag, it's ok )
Array
(
[root] => Array
(
[sometag] => hello
[items] => Array
(
[item] => first item
[item-1] => second item
[item-2] => third item
)
)
)
Does anybody has an idea on how to store xml in an assoc array as close as
possible to the original structure ?
IMHO, t3lib_div::xml2array() doesn't do it at best, cause collections are
frequently used in xml files.
Voila :)
Jerome Schneider
More information about the TYPO3-dev
mailing list