TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   General (http://www.talkphp.com/general/)
-   -   Parse Podcast XML and put up instance of player (http://www.talkphp.com/general/3603-parse-podcast-xml-put-up-instance-player.html)

buildakicker 11-13-2008 07:15 PM

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!

Salathe 11-13-2008 09:07 PM

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".

buildakicker 11-13-2008 10:12 PM

You answered what I was asking even thought I didn't ask. :) Brain waves.

buildakicker 11-13-2008 11:55 PM

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

ie:

foreach($items as $item){
echo $item NUMBER?
}

awuehr 11-14-2008 06:19 AM

With
PHP Code:

foreach($items as $key => $item)
    echo 
$item,$key

you get the key of the array.

Measter 11-14-2008 12:31 PM

If the keys are named rather than numbered, you could do a for loop, and output the counter.

Salathe 11-14-2008 02:02 PM

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"]] :-)

buildakicker 11-14-2008 05:42 PM

non php5
 
i'd love to indulge in XPATH on my www server, but my company doesn't/won't upgrade to php5. BAH!


All times are GMT. The time now is 10:55 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0