I can only get the league name "$league" to display for the first group of games (only 1 in first grp). What am I doing wrong?
For the champions league games for example league name should be displayed once above that group of games.
I guess I am doing something wrong with the foreach.
<?php
$dom = new DomDocument;
$dom->load('http://ads-cdn.unibet.com/orval/feed/uk/en/sportsBookCopy.xml');
$dom->preserveWhiteSpace = false;
$mainnote = $dom->getElementsByTagName('pool');
$note = $dom->getElementsByTagName('event');
foreach ($mainnote as $mainvalue) {
$pool= $mainvalue->getElementsByTagName('pool')->item(0)->nodeValue;
$league= $mainvalue -> getAttribute('name');
echo $league . ' (League Name)<br />';
foreach ($note as $value) {
$event= $value->getElementsByTagName('event')->item(0)->nodeValue;
$name= $value -> getAttribute('name');
echo $name . '<br />';
$alt = $value->getElementsByTagName('outcome');
$alt2 = $value->getElementsByTagName('price');
$length = $alt->length;
for ($index = 0; $index < $length; $index++) {
$label = $alt->item($index)->attributes->getNamedItem('label')->nodeValue;
$odds = $alt2->item($index)->attributes->getNamedItem('odds')->nodeValue;
echo $label . ' : ' . $odds . '<br />';
}
echo '---------------' . '<br />';
}
}
?>
Here is the result of the parsed xml file: http://www.cjhweb.se/Oddstest/unibet_test.php
This is the source xml: http://ads-cdn.unibet.com/orval/feed/uk/en/sportsBookCopy.xml