Im really new to php and im trying to load in data from an external xml feed into a php document, then use that data to generate an output.
The xml feed im using is – http://whdn.williamhill.com/pricefeed/openbet_cdn?action=template&template=getHierarchyByMarketType&classId=1&marketSort=–&filterBIR=N
What im trying to do is generate a list of ‘markets’ and there names, so as the xml feed stands at the time of writing the first 3 items in the list would be :
- Scottish Division 1 – Outright – Outright
- Dumbarton v Hamilton – 1st Half Result/2nd Half Result
- Dumbarton v Hamilton – Match Handicaps
at the moment im trying to use the code bellow to achieve this, but im getting nowhere quickly with it, any ideas on what im doing wrong here ?
just a further piece of background, im using php 5.4.4, am i right in thinking that simplexml comes already pre installed.. so i dont need to add any thing additional here ?
<?php
$xml = simplexml_load_file('http://whdn.williamhill.com/pricefeed/openbet_cdn?action=template&template=getHierarchyByMarketType&classId=1&marketSort=--&filterBIR=N');
foreach ($xml->market as $event) {
echo $event;
}
?>
You need to drill down through the xml to get the markets, and then get the attributes of the market: