unerd.co.uk Posted February 9, 2008 Share Posted February 9, 2008 Hi all, i desperately need your help! I am looking at this feed http://www.sportbet.com/BJFeed/xmlscores.aspx however the results returned are very mixed. I would like to break down the results to display by a certain IdLeague or IdSport. However these are only defined within the results and not the xml file structure. Basically is it possible for me to feed in results by a certain result e.g. returning results for IdLeague 4 etc? Thank you for your time, Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted February 9, 2008 Share Posted February 9, 2008 You can do something like this: <?php $xml = new SimpleXMLElement('http://www.sportbet.com/BJFeed/xmlscores.aspx', null, true); $xpath_result = $xml->xpath('Game[idLeague="4"]'); foreach($xpath_result as $item) { print_r($item); } ?> What you need to use is XPath. Quote Link to comment Share on other sites More sharing options...
unerd.co.uk Posted February 9, 2008 Author Share Posted February 9, 2008 Thank you Daniel! That's great, but how would i then break it down to pull out cerain results at the moment i get - SimpleXMLElement Object ( [VisitorTeam] => FLAMENGO [HomeTeam] => VOLTA REDONDA [VisitorNss] => 169 [HomeNss] => 170 [idLeague] => 380 [idSport] => SOC [VisitorScore] => 2 [HomeScore] => 1 [GameDate] => 2/7/2008 4:30:00 PM ) How would i pick and choose which elements are displayed and also how would i stop the element name (e.g. VisitorTeam) showing? Thanks again, Dave Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted February 9, 2008 Share Posted February 9, 2008 Just do whatever you want with the individual result within the foreach loop. I just used print_r() to show that it gets it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.