Is this something like what you are looking for?
$myArray = Array();
$currentKey;
foreach($xml->dict[0] as $dict1){
foreach($dict1->children() as $dictChild){
if($dictChild->getName() == "key"){
$currentKey = $dictChild;
} else {
$myArray[(string)$currentKey] = (string)$dictChild;
}
}
}
UPDATE I tested out the code and I was getting the warning that you were getting. Casting to strings seems to fix that. Below is the example file I made and the output I am getting.
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
$myArray = Array();
$currentKey;
$xml;
if (file_exists('test.xml'))
$xml = simplexml_load_file('test.xml');
foreach($xml->dict[0] as $dict1){
foreach($dict1->children() as $dictChild){
if($dictChild->getName() == "key"){
$currentKey = $dictChild;
} else {
$myArray[(string)$currentKey] = (string)$dictChild;
}
}
}
print '<pre>';
print_r($myArray);
print '</pre>';
?>
Array
(
[Track ID] => 0
[Name] => American Idol 2013
[Artist] => Amber Holcomb
[Album Artist] => Amber Holcomb
[Album] => Unknown Album
[Kind] => MPEG audio file
[Size] => 3645
[Total Time] => 233000
[Date Modified] => Thu Mar 14 12:11:12 2013
[Date Added] => Thu Apr 04 16:10:15 2013
[Bitrate] => 128
[Location] => file://localhost/Z:%5Canthony%5CMusic%5CiTunes%5CiTunes%20Media%5CMusic%5CUnknown%20Artist%5CUnknown%20Album%5CAmber%20Holcomb%20-%20A%20Moment%20Like%20This%20-%20Studio%20Version%20-%20American%20Idol%202013.mp3
[File Folder Count] => -1
[Library Folder Count] => -1
)