PDA

View Full Version : PHP GD and XML?



Johno
17-10-2008, 11:43 PM
Hey :)

Right, well I am trying to create a dynamic signature for myself using the Last.FM API and PHP GD.

I'm wanting it to show the most recent track played, and that is outputted in XML but I don't know how to go from the XML to it then being put into the PHP GD and then outputted?

All help appreciated! (Sorry if its not described too well lol)

Trigs
17-10-2008, 11:53 PM
Hey :)

Right, well I am trying to create a dynamic signature for myself using the Last.FM API and PHP GD.

I'm wanting it to show the most recent track played, and that is outputted in XML but I don't know how to go from the XML to it then being put into the PHP GD and then outputted?

All help appreciated! (Sorry if its not described too well lol)

I don't know any PHP/XML Integration but you could use

file_get_contents('www.site.com/lol.xml');

and explode the tags containing the info you want to display.

Johno
19-10-2008, 11:00 AM
When I use file_get_contents, I get this output shown on this page http://johnathanlaw.com/sig2.php

Now how do I use explode to get the data I want from that? :)

Invent
19-10-2008, 11:08 AM
Do:


$xml_file = file_get_contents('www.site.com/lol.xml');
$name = preg_match( '#<name>(.*?)</name>#', $xml_file, $matches );
$name = $matches[ 1 ];
to parse the name of the song. Hopefully that'll work & get you started ;)

Johno
19-10-2008, 11:26 AM
Thank yoooou :) +rep to you both

Gotta spread before I can give it to you again Simon

Thread Closed

Want to hide these adverts? Register an account for free!