Results 1 to 2 of 2

Thread: RSS feed not displaying as html

  1. #1
    Join Date
    Oct 2005
    Location
    Joysee
    Posts
    6

    RSS feed not displaying as html

    I'm using a script to add RSS feeds to my site but unfortunately if the feed returns html, the information is being displayed as text instead of html. Can someone point out to me what I'm missing. Here's the script:

    Code:
    <?php
    $insideitem = false;
    $tag = "";
    $title = "";
    $description = "";
    $link = "";
    $locations = array('http://rss.news.yahoo.com/rss/topstories');
    srand((float) microtime() * 10000000); // seed the random gen 
    $random_key = array_rand($locations);
    function startElement($parser, $name, $attrs) {
     global $insideitem, $tag, $title, $description, $link;
     if ($insideitem) {
      $tag = $name;
     } elseif ($name == "ITEM") {
      $insideitem = true;
     }
    }
    function endElement($parser, $name) {
     global $insideitem, $tag, $title, $description, $link;
     if ($name == "ITEM") {
      printf("<dt><b><a href='%s'>%s</a></b></dt>",
      trim($link),htmlspecialchars(trim($title)));
      printf("<dt>%s</dt><br><br>",htmlspecialchars(trim($description)));
      $title = "";
      $description = "";
      $link = "";
      $insideitem = false;
     }
    }
    function characterData($parser, $data) {
     global $insideitem, $tag, $title, $description, $link;
     if ($insideitem) {
     switch ($tag) {
      case "TITLE":
      $title .= $data;
      break;
      case "DESCRIPTION":
      $description .= $data;
      break;
      case "LINK":
      $link .= $data;
      break;
     }
     }
    }
    ?>
    Thanks much.

  2. #2
    Join Date
    Oct 2006
    Posts
    26
    You will have to supply more information than this. Are you trying to use another site's RSS to fill content on your site? Also, the RSS is simply an XML file you then can do what you like with it. It doesn't just make a web page itself.

    The text file that the script is creating is probably right - you just have to do somethihng with it then - like use it as an include on a web page etc.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •