I am trying to parse an XML file so that I get all of the records from the <pid> tags that start with a ‘b’ as shown:

The link to the xml file is:
http://www.bbc.co.uk/radio1/programmes/schedules/england.xml
And the code I have so far is:
<?php
$xml = simplexml_load_file('http://www.bbc.co.uk/radio1/programmes/schedules/england.xml');
foreach($xml->day>broadcasts->broadcast as $pid){
echo $pid->programme->pid;
}
?>
As far as my knowledge goes, this foreach statement should echo out all of the pid records, where it only does the first one.
Any ideas on where my code is going wrong as to how I make it output all of them?
Your loop needs to go one level deeper, since the
programmenodes are multiple children of a singlebroadcastnode. You therefore need to loop over all theprogrammenodes in eachbroadcastnode to echo out theirpid