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, Link to comment https://forums.phpfreaks.com/topic/90197-xml-feed-display-results-by-keyword/ 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. Link to comment https://forums.phpfreaks.com/topic/90197-xml-feed-display-results-by-keyword/#findComment-462636 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 Link to comment https://forums.phpfreaks.com/topic/90197-xml-feed-display-results-by-keyword/#findComment-462748 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. Link to comment https://forums.phpfreaks.com/topic/90197-xml-feed-display-results-by-keyword/#findComment-462758 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.