unistake Posted July 23, 2009 Share Posted July 23, 2009 Hi all, I am trying to extract some information from a website, however need some help in to how to put the xml files in to php variables. I understand just about this code! <?php $data = file_get_contents("http://www.bluesq.com/bluesq_php/cubs/cubs.php?action=getpage&thepage=385.xml"); ?> However the data in the page above is repeated with different values like this.. <BSQCUBS Version="0.04" Date="Thu Jul 23 16:00:39 BST 2009" MachineDate="Thu, 23 Jul 2009 16:00:39 +0100"> − <Class class_id="385"> <Title>Football Matches</Title> − <Type type_id="5143" type_minbet="0" type_maxbet="0"> <Title>UEFA Europa League</Title> − <Event start_time="2009-07-23 16:00:00" ev_id="1948510" ev_minbet="0.01" ev_maxbet="1000.0" racetype="" tracktype="" handicap=" " trifecta=" " eligibility="" distance="" going="0" class="0"> <Description>Karabakh Agdam v Rosenborg</Description> − <Market mkt_typ="Win/Draw/Win" lp_avail="Y" sp_avail="N" mkt_id="3054130"> − <Occurrence bet_id="23101981" lp_num="1" lp_den="4" decimal="1.25" oc_minbet="0.5" oc_maxbet="500.0"> <Description>Rosenborg</Description> </Occurrence> − <Occurrence bet_id="23101980" lp_num="15" lp_den="4" decimal="4.75" oc_minbet="0.5" oc_maxbet="80.0"> <Description>Draw</Description> </Occurrence> − <Occurrence bet_id="23101979" lp_num="11" lp_den="1" decimal="12" oc_minbet="0.5" oc_maxbet="230.0"> <Description>Karabakh Agdam</Description> </Occurrence> </Market> There are several other 'Markets' in the xml file however I would like to extract the above so that I can have something in the order of... $game_date = EventStartTime; $homeodds = EventDecimals; etc If anyone knows how to do this it would be much appreciated, also any links for learning this sort of extraction would be great. Thanks Link to comment https://forums.phpfreaks.com/topic/167135-extract-live-feeds-from-an-xml-page/ Share on other sites More sharing options...
JonnoTheDev Posted August 11, 2009 Share Posted August 11, 2009 Use a parser i.e. simpleXML $xml = simplexml_load_string($data); http://uk3.php.net/manual/en/intro.simplexml.php Link to comment https://forums.phpfreaks.com/topic/167135-extract-live-feeds-from-an-xml-page/#findComment-895549 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.