•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 425,999 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 1,691 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 1387 | Replies: 2
![]() |
•
•
Join Date: May 2004
Location: Boston,MA
Posts: 1,362
Reputation:
Rep Power: 7
Solved Threads: 17
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]<?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*/
?>[/PHP]
and here is the xml with some example songs
here is my php:
[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*/
?>[/PHP]
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>
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.
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.
Last edited by iamthwee : Jul 20th, 2006 at 6:21 am.
I'm not a programmer. My attitude starts with ignorance, holds steady at conversation, and ends with a trip to the hospital. Get used to it.
•
•
Join Date: May 2004
Location: Boston,MA
Posts: 1,362
Reputation:
Rep Power: 7
Solved Threads: 17
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.
![]() |
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- [urgent] HTML form => XML file (JSP)
- Parsing xml file (Python)
- saving xml file from servlet request instance (Java)
- Unzip zipped xml file (VB.NET)
- problem reading xml file in c# (C#)
- parsing error (XML file-java-schema) (Java)
- Pass XML file contents to a hash table. (Java)
Other Threads in the PHP Forum
- Previous Thread: Floating IP Address in AOL
- Next Thread: PHP safe_mode & effects of turning it off...



Linear Mode