<?php
$data = simplexml_load_file('Library.xml');
$properties = array('Name', 'Artist', 'Album', 'Rating');
$count = 0;
foreach ($data->dict->dict->dict as $tune) {
$song = new song;
$next = false;
foreach ($tune as $property) {
if ($next != false) {
// this is such an ugly hack, but otherwise the data was still in a simpleXMLObject
// and I didn't know how to get it out - somebody help me out here
ob_start();
print($property);
$song->$next = ob_get_contents();
ob_end_clean();
}
if (in_array($property, $properties)) {
$next = strtolower($property);
} else {
$next = false;
}
}
if ($song->insert()) {
$count++;
}
}
?>