我正在使用此代码,我只是获得1个体育数据并不是所有,它只是重复1次赔率数据。请检查
<?php
$xml = simplexml_load_file('demo.xml');
foreach($xml->Game->children() as $a => $b) {
echo $b['Name'].$b['ID'].'<br>';
foreach($xml->Game->SportsBook->children() as $c => $d) {
echo $d['LineType'].$d['LastUpdated'].'<br>';
}
}
print_r($xml->Game->SportsBook)
?>
答案 0 :(得分:1)
我认为你在理解数据嵌套方面遇到了问题,我认为这会给你一个更好的起点......
foreach($xml->Game->SportsBook as $d) {
echo $d['Name'].' '.$d['ID'].'<br>';
foreach( $d->Odds as $odds) {
echo $odds['LineType'].' '.$odds['LastUpdated']."\n";
}
}