I 'm a total PHP beginner and need some help :-)
Have this xml:
And this scrypt:
<?php // Retrieve XML File $file = file_get_contents('livescore-feed.xml'); // Parse XML with SimpleXML $livescore_data = new SimpleXMLElement($file); foreach ($livescore_data->league as $league) { echo "<table class='table table-striped table-bordered table-condensed'>"; echo "<thead><tr><th colspan='6' id='league'>" . $league->attributes()->name . "</th></tr></thead>"; echo "<tbody>"; foreach ($league->match as $match) { $status = $match->attributes()->status; $home = $match->home->attributes()->name; $away = $match->away->attributes()->name; $score = $match->home->attributes()->goals . " - " . $match->away->attributes()->goals; // If match not yet started, there will be a ":" in 'status' attribute if (strpos($match->attributes()->status,':') !== false) { $score = "-"; } echo "<tr><td class='status' id='match'>" . $status . "</td><td id='match' colspan='2'>" . $home . "</td><td class='score' id='match'>" . $score . "</td><td id='match' colspan='2'>" . $away . "</td> </tr>"; } echo "</tbody></table>"; } ?>
How to show/parse "events" also
Thank you very much for your help and suggestions
No comments:
Post a Comment