load($xml);
//get and output "- " elements
$x=$xmlDoc->getElementsByTagName('item');
for ($i=0; $i<=5; $i++)
{
$item_title=$x->item($i)->getElementsByTagName('title')
->item(0)->childNodes->item(0)->nodeValue;
$item_link=$x->item($i)->getElementsByTagName('link')
->item(0)->childNodes->item(0)->nodeValue;
$item_date=$x->item($i)->getElementsByTagName('pubDate')
->item(0)->childNodes->item(0)->nodeValue;
if (strlen($item_date) == 29)
$item_date= substr($item_date, 0, 16);
elseif (strlen($item_date) == 28)
$item_date= substr($item_date, 0, 15);
echo "\n".$item_date."
\n";
echo "\n";
echo "".$item_title." \n";
}
?>
|