User Name Password Register
DaniWeb IT Discussion Community
All
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
Reply
Join Date: May 2004
Location: Boston,MA
Posts: 1,362
Reputation: mikeandike22 is an unknown quantity at this point 
Rep Power: 7
Solved Threads: 17
Featured Blogger
mikeandike22's Avatar
mikeandike22 mikeandike22 is offline Offline
Nearly a Posting Virtuoso

Getting info from an XML file

  #1  
Jul 16th, 2006
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
<?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>
My Daniweb Blog: This,That, and Everything Else (Blog contest winner)

GetFirefox!
GetOpera!






AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2005
Posts: 4,782
Reputation: iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light 
Rep Power: 17
Solved Threads: 319
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Industrious Poster

Re: Getting info from an XML file

  #2  
Jul 20th, 2006
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.
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.
Reply With Quote  
Join Date: May 2004
Location: Boston,MA
Posts: 1,362
Reputation: mikeandike22 is an unknown quantity at this point 
Rep Power: 7
Solved Threads: 17
Featured Blogger
mikeandike22's Avatar
mikeandike22 mikeandike22 is offline Offline
Nearly a Posting Virtuoso

Re: Getting info from an XML file

  #3  
Jul 21st, 2006
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.
My Daniweb Blog: This,That, and Everything Else (Blog contest winner)

GetFirefox!
GetOpera!






Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 12:22 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC