[Typo3-dev] t3lib_div::xml2array() and collections

Martin Kutschker Martin.Kutschker at n0spam-blackbox.net
Wed Dec 14 09:46:22 CET 2005


Jerome schrieb:
> 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>";

Use the attribute "index".

$xml = '<root>
     <sometag>hello</sometag>
     <items>
         <item index="0">first item</item>
         <item index="1">second item</item>
         <item index="2">third item</item>
    </items>
</root>';

You can also use strings for the indices.

Masi




More information about the TYPO3-dev mailing list