Using an RSS Feed (This is Easy)

Discussion in 'XML & RSS' started by yfs1, Jan 5, 2005.

  1. mo16

    mo16 Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #261
    how are u guys doing, ive opened a website, and I was looking to use rss feeds from multiple news sources to display on a single page, thats the whole point of my website, its to make it convenient for people to get news from multiple news sources

    http://www.cricketnewsworld.com

    i looked around the web and looked at some scripts, packages such as carp where they charge

    but then i came around ur script, its perfect for me, the only problem is i get an error when I try to put more then one feed on my page

    I just copy and pasted ur script 3 times with different links, only the first one showed up

    im guessing its not desgined to function like that, since the variables are repeated

    Fatal error: Cannot redeclare startelement() (previously declared in /home2/cricketg/public_html/cricketnewsworld/index.php:241) in /home2/cricketg/public_html/cricketnewsworld/index.php on line 355

    thats the errror it shows, as you can see on my website there

    if you could shed some insight into this problem

    id be greatfull

    thanks
     
    mo16, May 4, 2008 IP
  2. kks_krishna

    kks_krishna Active Member

    Messages:
    1,495
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    80
    #262
    very useful.
     
    kks_krishna, May 4, 2008 IP
  3. Aaron111

    Aaron111 Well-Known Member

    Messages:
    4,301
    Likes Received:
    29
    Best Answers:
    0
    Trophy Points:
    185
    #263
    very powerful thanks I need help with rss Im offering placement on a huge traffic building site comin out soon anyone up for link exchange and free advertisement let know I need RSS feed in the site please ;) my sites domain is ewww.trafficbuilderssite.com it isn't online yet parked until it is powerfully equipet
     
    Aaron111, May 5, 2008 IP
  4. henery008

    henery008 Peon

    Messages:
    55
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #264
    Thanks a lot for this helpful thread. I hope this thread will definitely help me out. I will be back soon
     
    henery008, May 6, 2008 IP
  5. Aaron111

    Aaron111 Well-Known Member

    Messages:
    4,301
    Likes Received:
    29
    Best Answers:
    0
    Trophy Points:
    185
    #265
    any tips on getting RSS into my sites??? i have many please
     
    Aaron111, May 7, 2008 IP
  6. MacUser1

    MacUser1 Guest

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #266
    Hey, I sent you a PM about this.
     
    MacUser1, Jan 25, 2009 IP
  7. Aaron111

    Aaron111 Well-Known Member

    Messages:
    4,301
    Likes Received:
    29
    Best Answers:
    0
    Trophy Points:
    185
    #267
    I can Help no probes I can build you a feed in 10 minutes up on your sit.... let me know
     
    Aaron111, Jan 25, 2009 IP
  8. miealex

    miealex Active Member

    Messages:
    65
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    63
    #268
    Awesome little parser for any website that wants fresh content! Thanks a lot yfs1!
     
    miealex, Jan 26, 2009 IP
  9. Aaron111

    Aaron111 Well-Known Member

    Messages:
    4,301
    Likes Received:
    29
    Best Answers:
    0
    Trophy Points:
    185
    #269
    her egor whats the reference you have for us>>>>>
     
    Aaron111, Jan 26, 2009 IP
  10. whatinspiresu

    whatinspiresu Peon

    Messages:
    41
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #270
    i tried both straight and rotating codes and they work great! this is so simple thank you so much for sharing!!!

    i put it in a css styled div and it looks great already.

    like this:
    <style>
    .feed {width:500px; font:11pt arial;}
    .feed a{color:green}
    </style>
    
    <div class="feed"> code here </div>
    Code (markup):
    HOWEVER. its having trouble reading some ascii characters. is there a php fix out there that would help this code read correctly for a browser?

    PLUS. how would you control the amount of posts shown. can you set how many characters to show?

    ALSO. i want to pull in the images with it. is it hard to do?


    THANKS!
    Trisha
     
    whatinspiresu, Mar 11, 2009 IP
  11. hbsjcd3

    hbsjcd3 Active Member

    Messages:
    131
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    63
    #271
    Awesome thread... Learnig something new about RSS feeds everyday!
     
    hbsjcd3, Mar 16, 2009 IP
  12. namhay

    namhay Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #272
    Greetings all member here.

    I am a newbie for trying to read RSS into my website. But i face a problem when i upload to my Linux hosting server. You can see error here http://www.it-smart.biz/news/

    Error: XML error: mismatched tag at line 20

    But in my localhost testing is running well. So i asked my server they said that all functions are enabled. They ask me which function that we need to use? So they will enable more.

    Anyone face error like me? How to fix it?
     
    namhay, Jul 1, 2009 IP
  13. info@mantlo.com

    info@mantlo.com Peon

    Messages:
    51
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #273
    I will try this...looks promising at first sight.

    Will let u know my findings.;)
     
    info@mantlo.com, Feb 4, 2011 IP
  14. AndyMcL

    AndyMcL Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #274
    Is there any way of it changing to the next item in the feed after a set period of time? At the moment it only displays a list for me, but I want just one line to refresh with different items each time.
     
    AndyMcL, Jan 24, 2013 IP
  15. sem-profiteer

    sem-profiteer Active Member

    Messages:
    257
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    75
    #275
    I thought you would like a variation of this code. I make the feeds title and content shorter and added some formatting features.

    Change while ($int != 2){ === the number "2" to get more and less feeds. This feed gets 5 RSS links. It's great for a side bar.

            <?php
         
            $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><h3 class=\"h3\"><a href='%s'>%s</a></h3></dt>",
         
              trim($link),htmlspecialchars(substr($title,0,95) . "..."));
         
              printf("<dt><p>" . htmlspecialchars(substr($description,0,250)) . "...</p></dt>",h);
         
              $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://rssfeeds.webmd.com/rss/rss.aspx?cid=1010","r")
         
            or die("Error reading RSS data.");
         
            $int = 0;
            while ($int != 2){
            $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)));
         
            $int++;
            }
            fclose($fp);
            xml_parser_free($xml_parser);
         
            ?> 
    PHP:
     
    sem-profiteer, Mar 12, 2013 IP
  16. sedadi

    sedadi Greenhorn

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    21
    #276
    I can not copyng
     
    sedadi, Mar 27, 2013 IP