Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 4 of 4

Thread: RSS marquee

  1. #1
    Senior Member Dorky's Avatar
    Join Date
    Jun 2009
    Location
    Destin Florida
    Posts
    1,430
    Member #
    19103
    Liked
    4 times
    how could i use rss feeds to populate a marquee? no exp with xml.

    while($get_it !== true){ continue; }

  2.  

  3. #2
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,715
    Member #
    5580
    Liked
    717 times
    Dorky,
    Give us a link to your XML (RSS Feed).
    There are a few quirks about XML ... so if I could see the feed,
    I might have a sample script you can try.


  4. #3
    Senior Member Dorky's Avatar
    Join Date
    Jun 2009
    Location
    Destin Florida
    Posts
    1,430
    Member #
    19103
    Liked
    4 times
    sorry ml i dont have a chosen source yet. it is something i was considering for that chat site i revamped, by the way is looking much better now http://www.citicommons.com . but yeah i dont really know how to get started on doing this, so im wide open for a point in the right direction. thx in advance.

    while($get_it !== true){ continue; }

  5. #4
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,715
    Member #
    5580
    Liked
    717 times
    Some feeds are easy to do, others have malformed XML and others use ATOM.
    So, the required code can vary between them.

    For example, this is a script that uses CURL:
    PHP Code:
    <?php 
    // rss page for Co - 
    $feed_url "http://www.weather.gov/alerts/co.rss"

    # INITIATE CURL.
    $curl curl_init();

    # CURL SETTINGS.
    curl_setopt($curlCURLOPT_URL,"$feed_url");
    curl_setopt($curlCURLOPT_RETURNTRANSFER1);
    curl_setopt($curlCURLOPT_CONNECTTIMEOUT0);

    # GRAB THE XML FILE.
    $xmlTwitter curl_exec($curl);

    curl_close($curl);

    # SET UP XML OBJECT.
    $xml = new SimpleXMLElement($xmlTwitter);

    //echo "<pre>"; 
    //print_r($xml); 
    //echo "</pre>"; 

    foreach ($xml->channel->item as $item) { 
       echo 
    "Title: {$item->title}<br />"
       echo 
    "Description: " nl2br(trim($item->description,"\r\n")) . "<br /><br />"

    ?>

    This one does not use CURL:
    PHP Code:
    <?php

    function get_string_between($string$start$end){
            
    $string " ".$string;
            
    $ini strpos($string,$start);
            if (
    $ini == 0) return "";
            
    $ini += strlen($start);   
            
    $len strpos($string,$end,$ini) - $ini;
            return 
    substr($string,$ini,$len);
    }

            
    $feed_url "http://www.amazon.co.uk/rss/bestsellers/videogames?tag=AssocID-21";

    // Get XML 
    $xml=simplexml_load_file($feed_url);

    // How many items to display from the RSS Feed ...
    $count 3

    foreach (
    $xml->channel->item as $item) {
     
    // Parse-out the photo for each item ...
    $photo get_string_between($item->description'AssocID-21">','</a>');

    // Parse-out the cost for each item (buy new and crossed-out prices) ...
    $costs get_string_between($item->description'Buy new:</a>','</font>');

    $old_price get_string_between($costs'<strike>','</strike>');
    $buynew_price get_string_between($costs'<b>','</b>');
    $used_price get_string_between($item->description'<span class="price">','</span>');
    $quantity get_string_between($item->description'all">','</a>');

    $new_link get_string_between($item->description'<br /><br /><a href="','">Buy');
    $used_temp =get_string_between($item->description'</font> <br /><a href="','used & new');
    list (
    $used_link$no) = split ('\"'$used_temp);


    // If you don't want the # of the item to appear,
    // Use a modified title ... $short_title
    list ($no$short_title) = split (':'$item->title);


    if(
    $count 0){
    echo
    "
    <div class='recommends'>
    <a href='
    {$item->link}'>$photo</a><br />
    Original Title: <a href='
    {$item->link}'>{$item->title}</a><br />
    Shortened Title: 
    $short_title<br />
    old price: 
    $old_price<br />
    buy new price: 
    $buynew_price<br />
    used price: 
    $used_price<br />
    quantity: 
    $quantity<br />
    <br />
    <a href='
    {$new_link}'>buy new</a><br />
    <a href='
    {$used_link}'>buy used</a>
    <hr>
    <br /><br />
    "
    ;   

    }  
    $count--;  
    }
    ?>

    There is also a DOM method.

    It depends on how your webhost is configured and how the XML is formed.
    I can't use simplexml with one of my webhosts (they only allow CURL).



Remove Ads

Posting Permissions

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

Search tags for this page

marquee an rss feed

,

rss marquee

Click on a term to search for related topics.
All times are GMT -6. The time now is 12:48 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com