Here are the functions for generating the playlists, they aren't working at the moment because the DOMDocument keeps adding an xml declaration and putting the nodes in the wrong place.
function addTrack( &$doc , &$track )
{
$r = $doc->documentElement;
$b = $doc->createElement( "track" );
$elements = array( 'title', 'creator', 'location', 'image', 'info', 'identifier' );
foreach( $elements as $element ){
$createEl = $doc->createElement( $element );
$createEl->appendChild( $doc->createTextNode( $track[$element] ));
$b->appendChild( $createEl );
}
$r->appendChild( $b );
}
function updatePlaylist()
{
}
function createPlaylist( $path , $tracks )
{
$doc = new DOMDocument();
$doc->formatOutput = true;
foreach( $tracks as $track ){
$b = $doc->createElement( "track" );
$elements = array( 'title', 'creator', 'location', 'image', 'info', 'identifier' );
foreach( $elements as $element ){
$createEl = $doc->createElement( $element );
$createEl->appendChild( $doc->createTextNode( $track[$element] )
);
$b->appendChild( $createEl );
}
$r->appendChild( $b );
}
echo $doc->save( $path . 'playlist.xml' );
}
// read each filename as an entry
/* while ( false !== ( $file = readdir( $newhandle ) ) ){
// if the current entry is a . or a .. exclude it from the listing
if ( $file != "." && $file != ".." ){
echo "$file<br/>";
array_push( $files, $file );
}
} */
?>
heres the output
<?xml version="1.0"?>
<playlist xmlns="http://xspf.org/ns/0/" version="1">
<trackList>
<track>
<title>Homeland</title>
<creator>Postman</creator>
<location>http://www.jeroenwijering.com/upload/postmen.mp3</location>
<image>http://www.jeroenwijering.com/upload/postmen.jpg</image>
<info><![CDATA[http://www.amazon.com/Revival-Postmen/dp/B00005J8R7/sr=1-6/qid=1166887655/ref=sr_1_6/105-9454024-2355627?ie=UTF8&s=music]]></info>
<identifier>456</identifier>
</track>
<track>
<title>Jazzalude</title>
<creator>Basement Jaxx</creator>
<location>http://www.jeroenwijering.com/upload/basement.mp3</location>
<image>http://www.jeroenwijering.com/upload/basement.jpg</image>
<identifier>123</identifier>
<info><![CDATA[http://www.amazon.com/Rooty-Basement-Jaxx/dp/B00005K9V5/sr=8-3/qid=1166887603/ref=pd_bbs_sr_3/105-9454024-2355627?ie=UTF8&s=music]]></info>
</track>
<track>
<title>Sunshine Up Ahead</title>
<creator>Peter Jones</creator>
<location>http://www.jeroenwijering.com/upload/peterjones.mp3</location>
<image>http://www.jeroenwijering.com/upload/peterjones.jpg</image>
<info>http://www.peterjonesmusic.net</info>
<identifier>789</identifier>
</track>
</trackList>
<track><title>test3</title><creator>HB</creator><location>./music/011207/</location><image></image><info></info><identifier></identifier></track></playlist>