PRINT command for RSS feed

Discussion in 'PHP' started by Can, Aug 22, 2006.

  1. #1
    I tried the print command on my page to retreive the rss from it, but it doesn't seem to work:
    <?php PRINT"domain.com/rss.xml"; ?>

    Is there anything I can do to retireve my RSS feeds on my php or html pages.
     
    Can, Aug 22, 2006 IP
  2. wmtips

    wmtips Well-Known Member

    Messages:
    601
    Likes Received:
    70
    Best Answers:
    1
    Trophy Points:
    150
    #2
    Maybe something like this? :
    <?php print file_get_contents("domain.com/rss.xml"); ?>
     
    wmtips, Aug 22, 2006 IP
    Can likes this.
  3. Can

    Can Peon

    Messages:
    54
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    wow, but its comes out real bad, can I retrieve the info in a readable manner
     
    Can, Aug 22, 2006 IP
  4. wmtips

    wmtips Well-Known Member

    Messages:
    601
    Likes Received:
    70
    Best Answers:
    1
    Trophy Points:
    150
    #4
    It shows XML RSS source "as is". You need to parse XML and show and format data if you want to display it "user-friendly".
     
    wmtips, Aug 22, 2006 IP
  5. Cryogenius

    Cryogenius Peon

    Messages:
    1,280
    Likes Received:
    118
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Or, you need to set your content type... default will be html, which is no good if you're outputting RSS:

    header("Content-Type: application/rss+xml");
    PHP:
    Cryo.
     
    Cryogenius, Aug 22, 2006 IP
  6. Can

    Can Peon

    Messages:
    54
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    ?? How can I parse XML and how can we format it?
     
    Can, Aug 23, 2006 IP
  7. wmtips

    wmtips Well-Known Member

    Messages:
    601
    Likes Received:
    70
    Best Answers:
    1
    Trophy Points:
    150
    #7
    Use google, there are many examples and ready scripts to do that.

    Depending on version PHP has different sets of functions for dealing with XML:
    http://www.php.net/xml
    http://php.net/simplexml

    3d party libraries: PEAR, magpieRSS, etc.

    Just an easy google search results:

    RSS parsing using PEAR http://www.spoono.com/php/tutorials/tutorial.php?url=pear
    Parsing RSS 1.0 http://www.sitepoint.com/article/php-xml-parsing-rss-1-0
    Parsing XML With PHP http://www.wirelessdevnet.com/channels/wap/features/xmlcast_php.html
    Ready-to-use solution: http://www.googlerank.com/randomizing-for-ranking/random-rss-xml-feed-php.html
     
    wmtips, Aug 23, 2006 IP
  8. Gordaen

    Gordaen Peon

    Messages:
    277
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Depending on the purpose setting it as text/xml sometimes works better.

    header('Content-type: text/xml');
    PHP:
     
    Gordaen, Aug 23, 2006 IP