preserveWhiteSpace = false; $stats->load('stats.xml'); //Gets the team scores $homescore = $stats->getElementsByTagName('home')->item(0); $atthomescore = $homescore->getAttribute('scored'); $awayscore = $stats->getElementsByTagName('away')->item(0); $attawayscore = $awayscore->getAttribute('scored'); //Gets the scorers and minute scored. Needs to be an array. //Home $homegoals = $stats->getElementsByTagName('goal'); $arrhomegoals = array(); $arrawaygoals = array(); array_push($arrhomegoals, ''); array_push($arrawaygoals, ''); $homecount = 0; $awaycount = 0; $nodecount = 0; foreach ($homegoals as $scorer) { $attHome = $scorer->getAttribute('home'); if ($attHome=="1"){ $min = $scorer->getAttribute('min'); $tempgoal = $scorer->firstChild->nodeValue; $arrhomegoals[$homecount] = ($tempgoal." ".$min); $homecount++; } else { $min = $scorer->getAttribute('min'); $tempgoal = $scorer->firstChild->nodeValue; $arrawaygoals[$awaycount] = ($tempgoal." ".$min); $awaycount++; } } //Gets the players with a caution and sending off. Needs to be an array. $homeCards = $stats->getElementsByTagName('goal'); $arrHomeCards = array(); $arrAwayCards = array(); $countHomeCards= 0; $countAwayCards= 0; $yellowFinal=""; $cardFinal=""; array_push($arrHomeCards, ''); array_push($arrAwayCards, ''); foreach ($homeCards as $caution) { $attHome = $caution->getAttribute('home'); if (attHome=="1"){ $yellow = $caution->getAttribute('yellow'); if ($yellow == 1){ $yellowFinal = "(Y)"; } else { $yellowFinal = ""; } $red = $caution->getAttribute('red'); if ($red == 1){ $cardFinal = $yellowFinal."(R)"; } else { $cardFinal = $yellowFinal.""; } $tempPlayer = $caution->firstChild->nodeValue; $arrHomeCards[$countHomeCards] = ($tempPlayer.$cardFinal); $countHomeCards++; } else { $yellow = $caution->getAttribute('yellow'); if ($yellow == 1){ $yellowFinal = "(Y)"; } else { $yellowFinal = ""; } $red = $caution->getAttribute('red'); if ($red == 1){ $cardFinal = $yellowFinal."(R)"; } else { $cardFinal = $yellowFinal.""; } $tempPlayer = $caution->firstChild->nodeValue; $arrAwayCards[$countAwayCards] = ($tempPlayer.$cardFinal); $countAwayCards++; } } //Gets the crowd figure. $crowd = $stats->getElementsByTagName('crowd')->item(0); $crowdsize = $crowd->firstChild->nodeValue; //Gets the referee. $referee = $stats->getElementsByTagName('referees')->item(0); $referees = $referee->firstChild->nodeValue; echo "
\"\"/
\"\"/
".$atthomescore."
".$attawayscore."
Scorers
Scorers
"; foreach ($arrhomegoals as $homescorers){ echo "

$homescorers

"; } echo "
"; foreach ($arrawaygoals as $awayscorers){ echo "

$awayscorers

"; } echo "
Cards
Cards
"; foreach ($arrHomeCards as $homescards){ echo "

$homecards

"; } echo "
"; foreach ($arrAwayCards as $awaycards){ echo "

$awaycards

"; } echo "

Crowd: ".$crowdsize."

Referee: ".$referees."

"; ?>
field