TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,963
  • Latest: BiZaJe
Stats
  • Total Posts: 195,917
  • Total Topics: 21,308
  • Online today: 445
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 485
  • Total: 485

Pulling RSS Feed Into An PHP Article

Started by Max, July 26, 2006, 03:58:25 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

sanax

Quote from: Lesmondâ„¢ on March 20, 2007, 09:29:04 PM
I have a PHP version here you could try works in any block or article, not tested it with xml feeds though

// An RSS Reader to grab news from whichever site you choose
$backend = "Place feed here inside the qoutes "; //change this to match the rss feed url you wish to display.
// end


function endtheElement($parser, $tagName) {
// This function is used when an end-tag is encountered.
global $insideitem, $tag, $title, $description, $link;
 
  if ($tagName == "ITEM") {
    echo '<table width="100%" border="0"><tr>
      <td class="main-table">
      <span class="nav-head"><strong>
      ';
    printf("<p><b><a href='%s'>%s</a></b></p>", // make our title into an actual link
    trim($link),htmlspecialchars(trim($title))); // remove html characters from the title
 
    echo "</tr>";
    echo '<tr>
      <td class="nav">';
    printf("<p>%s</p>",$description); // Print out the live journal entry
    echo"</td>";
    echo "</tr>";
    echo "</table>";
    echo "<br>";
    $title = $description = $link = $insideitem = false;
   }
}

// Now to the parsing itself. Starts by creating it:

$xml_parser = xml_parser_create();

// Then setup the handlers:

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

// Open the actual datafile:

$fp = fopen($backend, r);

// Run through it line by line and parse:

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)));
}

// Close the datafile

fclose($fp);

// Free any memmory used

xml_parser_free($xml_parser);


This code works perfect! Any idea how I can set the items to show? At the moment it shows all the items available in the feed. Thx


srm

IM still waiting for someone to tell me where the hell I find rss instead of xml. All the feeds i have found relative to my genre are all in xml

rebelrose

Quote from: srm on March 30, 2007, 06:42:45 PM
IM still waiting for someone to tell me where the hell I find rss instead of xml. All the feeds i have found relative to my genre are all in xml

We are sorry if your questions are not answered fast enough for you. We try the best we can to answer all questions, however if we are too slow you can ry the SMF site for your question.

Thank You.

srm

i never said anything about response time . Im still waiting patiently.

majo

Have you tried rss feeder, topix google ? google usualy puts out in RSS instead of xml ?

what is your topic i might be able to do better research ?

srm

well if ound a page with tons of xml feeds that where about the dance music scene and the latest dance and electronica music news like charts latest releases etc. but they are all xml

superQ

I have this on my computer. I never used it though

http://www.extralabs.net/

it is the rss feed editor. as you can see in the attach it says it can edit xml feeds to rss. I do not know how it works but it might be worth a try,since what you are looking for seems to be all xml...

hawke

Im not sure this will help you out.  I am using xml feeds in a script box and they seem to work fine the code for the weather channel is

<div id="wx_module_737">
   39564 (Ocean Springs Weather Forecast, MS)
</div>

<script type="text/javascript">

   /* Locations can be edited manually by updating 'wx_locID' below.  Please also update */
   /* the location name and link in the above div (wx_module) to reflect any changes made. */
   var wx_locID = '39564';

   /* If you are editing locations manually and are adding multiple modules to one page, each */
   /* module must have a unique div id.  Please append a unique # to the div above, as well */
   /* as the one referenced just below.  If you use the builder to create individual modules  */
   /* you will not need to edit these parameters. */
   var wx_targetDiv = 'wx_module_737';

   /* Please do not change the configuration value [wx_config] manually - your module */
   /* will no longer function if you do.  If at any time you wish to modify this */
   /* configuration please use the graphical configuration tool found at */
   /* https://registration.weather.com/ursa/wow/step2 */
   var wx_config='SZ=180x150*WX=FHW*LNK=SSNL*UNT=F*BGI=spring*MAP=null|null*DN=www.mgcdadarts.com*TIER=0*PID=1035884805*MD5=e7ec93fc04cdf7cc1d9e716a6d8a2826';

   document.write('<scr'+'ipt src="'+document.location.protocol+'//wow.weather.com/weather/wow/module/'+wx_locID+'?config='+wx_config+'&proto='+document.location.protocol+'&target='+wx_targetDiv+'"></scr'+'ipt>'); 
</script>

you can see it at www.mgcdadarts.com

Xildjian

Quote from: Lesmondâ„¢ on March 20, 2007, 09:29:04 PM
I have a PHP version here you could try works in any block or article, not tested it with xml feeds though

// An RSS Reader to grab news from whichever site you choose
$backend = "Place feed here inside the qoutes "; //change this to match the rss feed url you wish to display.
// end


function endtheElement($parser, $tagName) {
// This function is used when an end-tag is encountered.
global $insideitem, $tag, $title, $description, $link;
 
  if ($tagName == "ITEM") {
    echo '<table width="100%" border="0"><tr>
      <td class="main-table">
      <span class="nav-head"><strong>
      ';
    printf("<p><b><a href='%s'>%s</a></b></p>", // make our title into an actual link
    trim($link),htmlspecialchars(trim($title))); // remove html characters from the title
 
    echo "</tr>";
    echo '<tr>
      <td class="nav">';
    printf("<p>%s</p>",$description); // Print out the live journal entry
    echo"</td>";
    echo "</tr>";
    echo "</table>";
    echo "<br>";
    $title = $description = $link = $insideitem = false;
   }
}

// Now to the parsing itself. Starts by creating it:

$xml_parser = xml_parser_create();

// Then setup the handlers:

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

// Open the actual datafile:

$fp = fopen($backend, r);

// Run through it line by line and parse:

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)));
}

// Close the datafile

fclose($fp);

// Free any memmory used

xml_parser_free($xml_parser);


How would one go about getting this to work if the feed is not linked to a specific .rss or .xml file? I've tried the different rss readers posted in the forums, but none of them seem to work with this URL: http://st.flobbit.com/feed/atom/

THanks

This website is proudly hosted on Crocweb Cloud Website Hosting.