Free file hosting, free video sharing

<<< The Web Hosting >>>


Go Back   Noeman GSM > Webhosting & Website development > Website development > Programming

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-13-2007, 05:14 PM
Spiral's Avatar
CO-Admin
 
Join Date: Sep 2004
Location: Martil
Age: 25
Posts: 16,377
Reputation: 24497
Spiral Mega Super MemberSpiral Mega Super MemberSpiral Mega Super MemberSpiral Mega Super MemberSpiral Mega Super MemberSpiral Mega Super MemberSpiral Mega Super MemberSpiral Mega Super MemberSpiral Mega Super MemberSpiral Mega Super MemberSpiral Mega Super Member
Default Simple RSS Reader Script

Here is a script that you can use to read rss feeds, please take note this script don’t work to atom.xml.

You can modify or tweak this script to make it more powerful. Use the first script if you plan to use single rss feed only and the second code if you plan to rotate a feed.

To make this rss feed reader work, you need to replace the rss feed url with the source you want.

PHP Code:
<?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><b><a href=’%s’>%s</a></b></dt>",
trim($link),htmlspecialchars(trim($title)));
printf("<dt>%s</dt><br><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://michaelthompson.org/news/goo-world.xml","r")
or die(
"Error reading RSS data.");
while (
$data fread($fp4096))
xml_parse($xml_parser$datafeof($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);
?>
The second script

PHP Code:
<?php
$insideitem 
false;
$tag "";
$title "";
$description "";
$link "";
$locations = array(’http://michaelthompson.org/news/goo-world.xml’, ‘http://forums.seochat.com/external.php’, ‘http://michaelthompson.org/news/goo-world.xml’);
srand((float) microtime() * 10000000); // seed the random gen
$random_key array_rand($locations);
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><b><a href=’%s’ target=new>%s</a></b></dt>",
trim($link),htmlspecialchars(trim($title)));
printf("<dt>%s</dt><br><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($locations[$random_key], ‘r’)
or die(
"Error reading RSS data.");
while (
$data fread($fp4096))
xml_parse($xml_parser$datafeof($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);
?>
Reply With Quote
Sponsored Links
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 10:26 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
Copyright © 2004-2008 Noeman . All rights reserved
Internet Advertising | Mortgage Calculator | Enertia electric motorcycle | Web Advertising | Wills

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112