Diskuze: XML to PHP -> 50 tisic dat.
V předchozím kvízu, Online test znalostí PHP, jsme si ověřili nabyté zkušenosti z kurzu.
Zobrazeno 3 zpráv z 3.
//= Settings::TRACKING_CODE_B ?> //= Settings::TRACKING_CODE ?>
V předchozím kvízu, Online test znalostí PHP, jsme si ověřili nabyté zkušenosti z kurzu.
Zapomněl jsem jen vložit do pastebinu.
$xml = simplexml_load_file(”http://ban.tipsport.cz/f/oddsFeed.xml”);
Tak jsem na to na konec přišel...Brutalita ...aktuálně skoro 300 tisíc dat (Podle aktualizace Tipsportu cca každých 20 minut.)
Funguje to na principu
$xml->supersport[$CYKLUS]->sport[0]->competition[0]->match[0]->event[0]->opportunity[0]
Snad to třeba někomu pomůže, každopádně rád vysvětlím,
pakliže někdo bude chtít.
(Ještě budu nahrávat do MySQL)
<?php
/*
- supersport (name)
- sport (name)
- competition (id, name, annualName, url)
- match (id, matchId, name, dateClosed, url)
- event (name, eventType, eventTypeDescription)
- opportunity (number, type, typeName, shortName, fullName)
*/
$xml=simplexml_load_file("http://ban.tipsport.cz/f/oddsFeed.xml");
$super_c = count($xml->supersport);
for($super=0; $super < $super_c; $super++)
{
$opport_c = count($xml->supersport[$super]->sport[$sport]->competition[$compet]->match[$match]->event[0]->opportunity);
echo "<br><font color='red'>".$xml->supersport[$super]['name']."</font>";$x++;
$sport_c = count($xml->supersport[$super]->sport);
for($sport=0; $sport < $sport_c; $sport++)
{
echo "<br>".$xml->supersport[$super]->sport[$sport]['name'];$x++;
$compet_c = count($xml->supersport[$super]->sport[$sport]->competition);
for($compet=0; $compet < $compet_c; $compet++)
{
echo "<br>".$xml->supersport[$super]->sport[$sport]->competition[$compet]['name'];$x++;
$match_c = count($xml->supersport[$super]->sport[$sport]->competition[$compet]->match);
for($match=0; $match < $match_c; $match++)
{
echo "<br>".$xml->supersport[$super]->sport[$sport]->competition[$compet]->match[$match]['id'];$x++;
echo "<br>".$xml->supersport[$super]->sport[$sport]->competition[$compet]->match[$match]['matchId'];$x++;
echo "<br>".$xml->supersport[$super]->sport[$sport]->competition[$compet]->match[$match]['name'];$x++;
echo "<br>".$xml->supersport[$super]->sport[$sport]->competition[$compet]->match[$match]['dateClosed'];$x++;
echo "<br>".$xml->supersport[$super]->sport[$sport]->competition[$compet]->match[$match]['url'];$x++;
$event_c = count($xml->supersport[$super]->sport[$sport]->competition[$compet]->match[$match]->event);
for($event=0; $event < $event_c; $event++)
{
echo "<br>".$xml->supersport[$super]->sport[$sport]->competition[$compet]->match[$match]->event[$event]['name'];$x++;
echo "<br>".$xml->supersport[$super]->sport[$sport]->competition[$compet]->match[$match]->event[$event]['eventType'];$x++;
echo "<br>".$xml->supersport[$super]->sport[$sport]->competition[$compet]->match[$match]->event[$event]['eventTypeDescription'];$x++;
$opport_c = count($xml->supersport[$super]->sport[$sport]->competition[$compet]->match[$match]->event[$event]->opportunity);
for($opport=0; $opport < $opport_c; $opport++)
{
echo "<br> ".$xml->supersport[$super]->sport[$sport]->competition[$compet]->match[$match]->event[$event]->opportunity[$opport]['number'];$x++;
echo "<br> ".$xml->supersport[$super]->sport[$sport]->competition[$compet]->match[$match]->event[$event]->opportunity[$opport]['type'];$x++;
echo "<br> ".$xml->supersport[$super]->sport[$sport]->competition[$compet]->match[$match]->event[$event]->opportunity[$opport]['typeName'];$x++;
echo "<br> ".$xml->supersport[$super]->sport[$sport]->competition[$compet]->match[$match]->event[$event]->opportunity[$opport]['shortName'];$x++;
echo "<br> ".$xml->supersport[$super]->sport[$sport]->competition[$compet]->match[$match]->event[$event]->opportunity[$opport]['fullName'];$x++;
}
}
}
}
}
}
?>
Zobrazeno 3 zpráv z 3.