<?php
$file = 'http://www.google.com';
$doc = new DOMDocument();
@ $doc->loadHTML(file_get_contents($file));
echo $doc->getElementsByTagName('span')->item(2)->nodeValue;
if (0 != $element->length) 
{
    $content = trim($element->item(2)->nodeValue);
    if (empty($content)) 
    {
        $content = trim($element->item(2)->textContent);
    }
    echo $content . "\n";
}
?>
google.com のホーム サイトからスパン タグの内部コンテンツを取得しようとしています。このコードは最初の span タグを出力するはずですが、結果を出力していませんか?