php - simplexml_load_file() with non-standard XML file -
i'm having trouble using non-standard xml file simplexml_load_file(). here's code:
<?php $file = 'http://www.gostanford.com/data/xml/events/m-baskbl/2010/index.xml'; $xml = simplexml_load_file($file); echo 'displaying user names of xml file...<br />'; foreach($xml $event_date){ echo 'home: '.$event_date->hn.'<br />'; } ?>
as you'll see, nothing being output xml file, echo'd "home:"
any appreciated.
this xml data, nothing non-standard it:
<game_days> <event_date date="20101023"> <event id="1271699" local_time="6:00 pm pt" eastern_time="21:00" hc="stan" vc="" hn="stanford" vn="" hs="" vs=""/> </event_date>
the attribute looking 1 element level <event>
below.
, access attributes use array syntax instead:
foreach($xml $event_date){ echo $event_date->event['hn'];
Comments
Post a Comment