Hi, I am trying to parse the following XML file to grab just some of the information. However am having issues because it is not a standard format or well formed document. The XML I am trying to parse is http://xml.afl.com.au/expandablegamebar.aspx?roundid=777 I want to grab the Home team, away team, venue and start time out of each of the nodes so i can then import them into a databse. Can anyone give me any tips on how I could achieve this? Dan
im using SimpleXMLElement, just play around with it... <?php $xml_url = file_get_contents('http://xml.afl.com.au/expandablegamebar.aspx?roundid=777'); $xml = new SimpleXMLElement($xml_url); //print '<pre>'; //print_r($xml); //print '</pre>'; foreach($xml -> r -> m as $data) { echo "Venue:".$data -> attributes() -> ven ."<br />"; echo "Start Time:".$data -> attributes() -> starttime ."<br />"; echo "Away:".$data -> away -> attributes() -> name."<br />"; echo "Home:".$data -> home -> attributes() -> name."<br />"; } ?> PHP:
<?php $xml = simplexml_load_file("http://xml.afl.com.au/expandablegamebar.aspx?roundid=777"); foreach($xml->r->m as $value){ echo $value->attributes()->ven; echo $value->away->attributes()->name; echo $value->home->attributes()->name; } ?>