What's wrong with the fetch rss feed code? The hook_block() code is the following.

   // …      
   case 'view':
      $url = 'http://example.com/feed'; //the site's rss url
      $blocks['subject'] = t('on the bookshelf');
      $blocks['content'] = _mymodule_fetch_feed($url);
      return $blocks;
   // …

function _mymodule_fetch_feed($url,$num_itmes=3){
  $http_result = drupal_http_request($url);

  if ($http_result-&gt;code == 200) {
      $doc = simplexml_load_string($http_result-&gt;data);
      if ($doc === FALSE) {
        $msg = "error parsing booksheld xml for %url: %msg.";
        $vars = array('%url'=&gt;$url,'%msg'=&gt;$e-&gt;getMessage());
        watchdog('goodreads', $msg, $vars, WATCHDOG_WARNING);
        return t("Getting the bookshelf resulted in an error.");
      }

      return _mymodule_block_content($doc, $num_items);
    }
    else {
      $msg = 'No content from %url.';
      $vars = array('%url' =&gt; $url);
      watchdog('goodreads', $msg, $vars, WATCHDOG_WARNING);

      return t("The bookshelf is not accessible.");           
    }
  }
}

function _mymodule_block_content($doc, $num_items = 3) {
  $items = $doc-&gt;channel-&gt;item;
  $count_items = count($items);
  $len = ($count_items &lt; $num_items) ? $count_items : $num_items;
  $template = '&lt;div class="goodreads-item"&gt;'.'&lt;img src="%s"/&gt;&lt;br/&gt;%s&lt;br/&gt;by%s&lt;/div&gt;'; // Default image: 'no cover'.
  $default_img = 'http://www.example.com/images/nocover-60x80.jpg';
  $default_link = 'http://example.com/feed';
  $out = '';
  foreach ($items as $item) {  
    $author = check_plain($item-&gt;author_name);
    $title = strip_tags($item-&gt;title);
    $link = check_url(trim($item-&gt;link));
    $img = check_url(trim($item-&gt;book_image_url));

    if (empty($author)) {
      $author = '';
    }

    if (empty($title)) {
      $title = '';
    }
    if (empty($link)!== 0) { 
      $link = $default_link;
    }
    if (empty($img)) {
      $img = $default_img;
    }

    $book_link = l($title, $link);
    $out .= sprintf($template, $img, $book_link, $author);
  }

  $out .= '&lt;br/&gt;&lt;div class="goodreads-more"&gt;'. l('Goodreads.com', http://example.com').'&lt;/div&gt;';
  return $out;
}


I put this code in my module; it can get the data, but the links are all the same.(http://example.com). How can I make it work?
if (empty($link)!== 0) { 
  $link = $default_link;
}


That condition makes no sense. empty() never returns 0, it return TRUE or FALSE. Just use if (empty($link)) {.

Also, you probably want to use the Aggregator, or Feeds module.