TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 11-13-2008, 07:15 PM   #1 (permalink)
The Acquainted
 
buildakicker's Avatar
 
Join Date: Jan 2008
Posts: 119
Thanks: 21
buildakicker is on a distinguished road
Default Parse Podcast XML and put up instance of player

Hello all,

I am creating a podcast on a static website that uses an XML file for the podcast to work with iTunes, WinAmp, etc.... however, I would like to be able to parse the xml file and create a div with each mp3 having it's own Player. That way someone can get the podcast, or they can go directly to the page and listen to old ones right there... I have been thinking of using something like the 1 pixel out player, since it's clean and easy to use.

Thanks!
__________________
SkiLeases.com
buildakicker is offline  
Reply With Quote
Old 11-13-2008, 09:07 PM   #2 (permalink)
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

There wasn't any questions asked so I'm not really sure what's going on (unless you're just proudly announcing what you're working on).

You can parse the XML file really easily with SimpleXML, loop through all of the items displaying the required information in HTML form. Adding in the audio player is also very easy, just follow the instructions on their website for the "standalone player".
Salathe is offline  
Reply With Quote
The Following User Says Thank You to Salathe For This Useful Post:
buildakicker (11-13-2008)
Old 11-13-2008, 10:12 PM   #3 (permalink)
The Acquainted
 
buildakicker's Avatar
 
Join Date: Jan 2008
Posts: 119
Thanks: 21
buildakicker is on a distinguished road
Default

You answered what I was asking even thought I didn't ask. :) Brain waves.
__________________
SkiLeases.com
buildakicker is offline  
Reply With Quote
Old 11-13-2008, 11:55 PM   #4 (permalink)
The Acquainted
 
buildakicker's Avatar
 
Join Date: Jan 2008
Posts: 119
Thanks: 21
buildakicker is on a distinguished road
Default

Is there a way to grab what number the array is on in a FOREACH loop?

ie:

foreach($items as $item){
echo $item NUMBER?
}
__________________
SkiLeases.com
buildakicker is offline  
Reply With Quote
Old 11-14-2008, 06:19 AM   #5 (permalink)
The Contributor
 
awuehr's Avatar
 
Join Date: Oct 2008
Location: Nuremberg, Germany
Posts: 26
Thanks: 3
awuehr is on a distinguished road
Default

With
PHP Code:
foreach($items as $key => $item)
    echo 
$item,$key
you get the key of the array.
__________________
Send a message via ICQ to awuehr Send a message via Skype™ to awuehr
awuehr is offline  
Reply With Quote
Old 11-14-2008, 12:31 PM   #6 (permalink)
The Wanderer
 
Join Date: Nov 2008
Location: Plymouth, UK
Posts: 9
Thanks: 0
Measter is on a distinguished road
Default

If the keys are named rather than numbered, you could do a for loop, and output the counter.
Measter is offline  
Reply With Quote
Old 11-14-2008, 02:02 PM   #7 (permalink)
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

I often attack XML documents with an XPath query (eg, $xml->xpath('//channel/items')) which returns an array of matching elements, with numeric keys.

Also, using XPath, you could filter out only the items which have an mp3 enclosure (for the podcast) with a query like //channel/items[enclosure[@type="audio/mpeg"]]
Salathe is offline  
Reply With Quote
Old 11-14-2008, 05:42 PM   #8 (permalink)
The Acquainted
 
buildakicker's Avatar
 
Join Date: Jan 2008
Posts: 119
Thanks: 21
buildakicker is on a distinguished road
Default non php5

i'd love to indulge in XPATH on my www server, but my company doesn't/won't upgrade to php5. BAH!
__________________
SkiLeases.com
buildakicker is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 01:03 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design