RSS Feeds without Description

Discussion in 'XML & RSS' started by advancedfuture, Feb 21, 2006.

  1. #1
    I was interested in finding out how I can have an RSS feed on my site with just the links to the articles and no description of the article. Thanks a bunch :D
     
    advancedfuture, Feb 21, 2006 IP
  2. FireStorM

    FireStorM Well-Known Member

    Messages:
    2,579
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    175
    #2
    i am also interested in knowing this .. i know there is a recent Joomla component which can do this .
     
    FireStorM, Feb 21, 2006 IP
  3. advancedfuture

    advancedfuture Banned

    Messages:
    481
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Welp I got it.

    I found the RSS Parser that yfs1 wrote and modded the code so it doesn't show the descriptions. Heres the modified code:

    <?php
    $insideitem = false;
    $tag = "";
    $title = "";
    $description = "";
    $link = "";
    function startElement($parser, $name, $attrs) {
     global $insideitem, $tag, $title, $link;
     if ($insideitem) {
      $tag = $name;
     } elseif ($name == "ITEM") {
      $insideitem = true;
     }
    }
    function endElement($parser, $name) { 
     global $insideitem, $tag, $title, $link;
     if ($name == "ITEM") {
      printf("<dt><b><a href='%s'>%s</a></b></dt>",
      trim($link),htmlspecialchars(trim($title)));
      $title = "";
      $description = "";
      $link = "";
      $insideitem = false;
     }
    }
    function characterData($parser, $data) {
     global $insideitem, $tag, $title, $link;
     if ($insideitem) {
     switch ($tag) {
      case "TITLE":
      $title .= $data;
      break;
      case "DESCRIPTION":
      $description .= $data;
      break;
      case "LINK":
      $link .= $data;
      break;
     }
     }
    }
    $xml_parser = xml_parser_create();
    xml_set_element_handler($xml_parser, "startElement", "endElement");
    xml_set_character_data_handler($xml_parser, "characterData");
    $fp = fopen("http://michaelthompson.org/news/goo-world.xml","r")
     or die("Error reading RSS data.");
    while ($data = fread($fp, 4096))
     xml_parse($xml_parser, $data, feof($fp))
      or die(sprintf("XML error: %s at line %d",
       xml_error_string(xml_get_error_code($xml_parser)),  
       xml_get_current_line_number($xml_parser)));
    fclose($fp);
    xml_parser_free($xml_parser);
    ?>
    Code (markup):
    Enjoy, I know I will :D
     
    advancedfuture, Feb 21, 2006 IP