Results 1 to 2 of 2

Thread: Can a coder help me here?

  1. #1
    Junior Member guillaumeb's Avatar
    Join Date
    Oct 2003
    Location
    Nantes, France
    Posts
    35

    Can a coder help me here?

    I'm trying to implement RSS to my site. Basically I wanna display my blog entries on my website.
    my blog is located at:http://360.yahoo.com/imguillaume
    I got this script below from the internet and the thing is, it only displays the title but no date, noblog intro or content of any kind. Does someone know how to modify the script so that:
    -it displays the date of the post
    -it open links in a new window
    -and if possible it display right on my site the full content of my entries?
    This is how it looks right now:
    http://carboneyes.free.fr/blog.php
    Thanks



    $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("<p> <a href='%s'>%s</a><p>",
    trim($link),htmlspecialchars(trim($title)));
    //printf("%s<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;
    }
    }
    }

    $xml_parser = xml_parser_create();
    xml_set_element_handler($xml_parser, "startElement", "endElement");
    xml_set_character_data_handler($xml_parser, "characterData");

    $fp = fopen("http://blog.360.yahoo.com/rss-ndb0J1kzfqq8G0jaKFmLIgKl1w2e0KWPThI-","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)
    -G-
    Join me on Yahoo!

  2. #2
    Security Intelligence TZ Veteran cash_site's Avatar
    Join Date
    Jul 2002
    Location
    Software Paradise
    Posts
    3,735
    Code:
    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;
    I think you might have to add more cases in this switch

    case "CONTENT"
    $content .= $data

    other than that, not entirely sure.

    --- 0wN3D by 3gG ---

Posting Permissions

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