香港專業教育學院開始了我的新年計劃的一部分,並決定學習PHP的,因爲它的一部分我試着去解析一個xml提要,並且回顯包裹在<a>
標籤中的事件的名稱,將它們鏈接回xml飼料網站上的事件頁面
我覺得我得到了一切在,但我不能似乎明白爲什麼這個心不是工作我只是得到一個空白頁,如果有一個人能在正確的方向,將不勝感激指向我,歡呼聲
<?php
// F1 W/H xml feed
$xml = simplexml_load_file('http://whdn.williamhill.com/pricefeed/openbet_cdn?action=template&template=getHierarchyByMarketType&classId=5&marketSort=HH&filterBIR=N');
foreach ($xml->response->williamhill->class->type as $type) {
$type_attrib = $type->attributes();
echo "<h2>".$type_attrib['name']."</h2>"; //Title - in this case f1 championship
} ?>
<ul>
<?php
foreach($type->market as $event) {
echo "<li>";
echo "<a href="$event_attributes['url']">";
echo $event_attributes['name'];
echo "</a>";
echo "</li>";
}
?>
</ul>
一個空白的PHP頁面通常意味着一個錯誤。檢查錯誤日誌或開啓['display_errors'](http://php.net/manual/en/errorfunc.configuration.php#ini.display-errors) –
在php.ini/.htaccess中啓用'error_reporting'/.user.ini(在調用腳本中語法錯誤太晚)。 – mario
你的'$ event_attributes'數組是如何分析的? – hjpotter92