this question has answer here:
i have xml sheet want extract content from.
this how xml looks like:
<scores sport="soccer"> <script/> <category name="england: premier league" id="1204" file_group="england"> <matches date="aug 24" formatted_date="24.08.2013"> <match status="11:45" date="aug 24" formatted_date="24.08.2013" time="11:45" static_id="1483470" fix_id="1395250" id="1556405"> <localteam name="fulham" goals="?" id="9175"/> <visitorteam name="arsenal" goals="?" id="9002"/> <events/> <ht score=""/> </match> <match status="14:00" date="aug 24" formatted_date="24.08.2013" time="14:00" static_id="1483469" fix_id="1395249" id="1556404"> <localteam name="everton" goals="?" id="9158"/> <visitorteam name="west brom" goals="?" id="9426"/> <events/> <ht score=""/> </match> </matches> </category> </scores>
what want to attributes of nodes strings in php. example, want localteam-name , visitorsteam-name match 1556404 id (and mach)
is possible solve easily?
dan
use xpath:
$xml = simplexml_load_file('http://url.com/xml'); $localteamname = $xml ->xpath('/scores/category/matches/match[@id=1556404]/localteam/@name');