<?php
$req="http://api.rakuten.co.jp/rws/2.0/rest?operation=ItemRanking&version=2009-04-15&developerId=&affiliateId=&genreId=409365";

$string = preg_replace('/:/','_',file_get_contents($req));

$xml = simplexml_load_string($string) or die("XMLパースエラー");

$output = "<table>n";
foreach ($xml->Body->itemRanking_ItemRanking->Item as $item) {

$output.= "<tr><td><img src='" . preg_replace('/http_/','http:',$item->smallImageUrl) . "'></td>";
$output.= "<td>商品名:".$item->itemName</td></tr>"; //エラー出る場所です

}

$output .= "</table>n";

echo $output;

?>

エラーが出る場所はわかっているのですがなぜエラーが出るのかがわかりません
楽天APIのXMLをphpで表示したいと考えています

ご教授願います