WEB need help with this RSS script

Discussion in 'OT Technology' started by Oh its me 20, Mar 13, 2008.

  1. Oh its me 20

    Oh its me 20 New Member

    Joined:
    Sep 11, 2007
    Messages:
    1,042
    Likes Received:
    0
    How do I get it to display on 10 items? Its currently displaying 50+

     
  2. gobbles

    gobbles .

    Joined:
    May 6, 2006
    Messages:
    422
    Likes Received:
    0
  3. Ricky

    Ricky █▄ █▄█ █▄ ▀█▄

    Joined:
    Jun 17, 2005
    Messages:
    38,767
    Likes Received:
    6
    here ya go

    Code:
    <?php
    echo 'im gay';
    $currentlyinli = false;
    $currentlyindesc = false;
    $insideitem = false;
    $tag = "";
    $title = "";
    $description = "";
    $link = "";
    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),trim($title));
    printf("<dt>%s</dt><br><br>",htmlspecialchars(trim(substr($descrip tion,0,100)))) ; 
    $title = "";
    $description = "";
    $link = "";
    $insideitem = false;
    }
    }
    function characterData($parser, $data) {
    global $insideitem, $tag, $title, $description, $link, $currentlyinli, $currentlyindesc;
    if ($insideitem) {
    switch ($tag) {
    case "TITLE":
    if($currentlyinli == false){
    $currentlyinli = true;
    $title .= "<li>";
    }
    $title .= $data;
    break;
    case "DESCRIPTION":
    if($currentlyinli == true){
    $description .= "";
    $currentlyindesc = true;
    $currentlyinli = false;
    }
    $description .= $data;
    break;
    case "LINK":
    $currentlyindesc = false;
    $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("RSS URL GOES HERE","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);
    ?>
     
  4. danza

    danza New Member

    Joined:
    Jul 9, 2005
    Messages:
    1,319
    Likes Received:
    0
    Location:
    california
    i'm a noob but i noticed this in your endElement function

    trim($link),trim($title));

    I don't know if it'll do anything for the rest of the code but it seems the parenthesis don't match.
     
  5. noon

    noon get high and teach me how to listen

    Joined:
    May 4, 2002
    Messages:
    3,384
    Likes Received:
    0
    Location:
    Lawrence, KS
    The second parenthesis is from the printf.



    can you paste the output?
     
  6. 2ofdem

    2ofdem OT Supporter

    Joined:
    Jun 17, 2003
    Messages:
    114,854
    Likes Received:
    8
    Location:
    aus.vic.mel
    echo 'im gay'; :bowrofl:
     

Share This Page