Jump to content

XML feed - display results by keyword


unerd.co.uk

Recommended Posts

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

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.

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.