ok so i built a simple playlist type thing where the user can click a link and then the player will play that song. Now i would like for the page to get info from an xml file and then display a short description.

here is my php:

<?php
//select which song from url
$song = $_GET['song'];
$songfile = ''.$song.'.mp3';

//quicktime player that gets the source of the song from the url
echo '<embed qtsrc='.$songfile.' height"256" width="320" src='.$songfile.' type="image/x-quicktime" pluginspage="[http://www.apple.com/quicktime/download/]" autoplay="true">';

/*Display current song and short description*/
//point variable to songlist.xml
$songlist = "songlist.xml";
//connect to songlist.xml
$songxml = simplexml_load_file($songlist);

//set simple if statement that if a song is selected display song information 
if ( $song != NULL){
echo '<p id="soinginfo">Right now you are listing to '.$song.':<br/>'.$songxml->songlist->$song->description.'</p>';
}
/*End display info settings*/
?>

and here is the xml with some example songs

<?xml version="1.0" encoding="iso-8859-1"?>
<songlist>
 <title>Song List</title>
 <description>a list of songs and information</description>
 <shpadoinkle>
  <title>Shpadoinkle</title>
  <link>/jacobsite/Shpadoingkle.mp3</link>
  <description>
   My rendition of a song from Trey Parker’s first movie “Cannibal! The
   Musical.”  I will be recording more from this spectacular movie and
   making a CD (which will be called “Jake Sherman Plays Trey Parker.”)
   Find out more about “Cannibal! The Musical” here:
   http://www.cannibalthemusical.net/index.shtml 
  </description>
 </shpadoinkle> 
 <danicalifornia>
  <title>Dani California</title>
  <link>/jacobsite/Dani_California.mp3</link>
  <description>
   A Song by the Red Hot Chilli Peppers on their new cd "Stadium Arcadium".
  </description>
 </danicalifornia>
</songlist>
Member Avatar for iamthwee

It seems like you need a simple xml parser.

Read this. If you get stuck I'll probably be able to help you. I've written parsers in c++/java/c# so I shouldn't see php as a problem.

yea it was a lot simpler than that code made it out to be you just have to use the simplexml_load_file() command the problem i was having was i edited the xml and php so many times i lost track of capitilization and so the words werent matching up.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.