Simple PHP XML Parser



I'm a newbie to PHP so require some help if possible, it's probably a really simple answer but i'm struggling with it.


I'm trying to get some data from a William Hill XML feed.


I'd like to pull out:



  • Competition

  • Teams Playing

  • Kick Off Time

  • Team 1 + odds

  • Draw + odds

  • Team 2 + odds


Here is a link to the XML feed - http://ift.tt/1GJi35h


So far I have the code below which isn't pulling out all the data i need and it's only bring back one fixture.



<?php

$xml = simplexml_load_file('http://ift.tt/1GJi35h');


$data = $xml->response->williamhill->class->type->market;
$ps = $data->participant;
foreach($ps as $p)
{
echo $p['name']." - ".$p['odds']."<br />";
}

?>


Any help would be very much appreciated!


No comments:

Post a Comment