473,832 Members | 2,281 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Integrating RSS feed into a website..

I would like to integrate an RSS newsfeed into my website but can't
seem to figure out how.
Has anyone got any pointers for me?

E.
Jul 17 '05 #1
5 3561
Mayhem wrote:
I would like to integrate an RSS newsfeed into my website but can't
seem to figure out how.
Has anyone got any pointers for me?

E.

Yeah, search http://google.com and http://php.net for "PHP XML" or "PHP RSS
PARSING". There are dozens of sites that will tell you how to do this
already out there.
Jul 17 '05 #2
Mayhem wrote:
I would like to integrate an RSS newsfeed into my website but can't
seem to figure out how.
Has anyone got any pointers for me?

E.


use XSLT.

You will need to write an XSL template to convert the raw RSS formatted
XML into whatever HTML you want.

This might work:

$xh = xslt_create();
$html = xslt_process($x h, 'http://theSource/info.rss', 'rss2xhtml.xsl' );
echo $html;

You will obviously have to provide 'rss2xhtml.xsl' . See zvon.org for
tutorials and a crash course in writing XSLT templates.

don't concern yourself with parsing RSS. XML parsing built into the XSLT
processor will be enough for your needs.

If you're struggling with XSLT, join this mailing list, they are very
helpful. http://www.mulberrytech.com/xsl/xsl-list/index.html

Once you can do basic XML/XSLT transformations , you'll wonder how you
ever lived without it.

Also, if you're lazy ;)
you might want to check this out
http://www.2rss.com/index.php?rss=5894
Jul 17 '05 #3
On Thu, 22 Apr 2004 23:15:41 +0200, Mayhem in comp.lang.php wrote:
I would like to integrate an RSS newsfeed into my website but can't
seem to figure out how.
Has anyone got any pointers for me?


I had the same issue a few weeks ago. Using Google, I found a snippet which I
adapted to my needs. Here's something you might be able to work with;

<?php
$_item = array();
$_depth = array();
$_tags = array("dummy");

function initArray()
{
global $_item;

$_item = array ("TITLE"=>"" , "LINK"=>"",
"DESCRIPTION"=> "", "URL"=>"");
}

function startElement($p arser, $name){
global $_depth, $_tags, $_item;

if (($name=="ITEM" ) ||
($name=="CHANNE L")
|| ($name=="IMAGE" )) {
initArray();
}
@$_depth[$parser]++;
array_push($_ta gs, $name);
}

function endElement($par ser, $name){
global $_depth, $_tags, $_item;

array_pop($_tag s);
$_depth[$parser]--;
switch ($name) {
case "ITEM":
echo "<p><a href=\"{$_item['LINK']}
\">" .
"{$_item['TITLE']}</a></p>\n";
initArray();
break;

case "IMAGE":
echo "<a href=.{$_item['LINK']}.>" .
"<DEFANGED_ IMG src=.{$_item
['URL']}. " .
"alt=.{$_it em['TITLE']};
border=.0.></a>\n<br />\n";
initArray();
break;

case "CHANNEL":
echo "<h3>{$_ite m['TITLE']}</h3>\n";
initArray();
break;
}
}

function parseData($pars er, $text){
global $_depth, $_tags, $_item;

$crap = preg_replace ("/\s/", "", $text);
/* is the data just whitespace?
if so, we don't want it! */

if ($crap) {
$text = preg_replace ("/^\s+/", "", $text);
/* get rid of leading whitespace */
if (@$_item[$_tags[$_depth[$parser]]]) {
$_item[$_tags[$_depth[$parser]]] .=
$text;
} else {
$_item[$_tags[$_depth[$parser]]] =
$text;
}
}
}

function parseRDF($file) {
global $_depth, $_tags, $_item;

$xml_parser = xml_parser_crea te();
initArray();

/* Set up event handlers */
xml_set_element _handler
($xml_parser, "startEleme nt", "endElement ");
xml_set_charact er_data_handler
($xml_parser, "parseData" );

/* Open up the file */
$fp = fopen ($file, "r") or die ("Could not
open $file for input");

while ($data = fread ($fp, 4096)) {
if (!xml_parse($xm l_parser, $data, feof
($fp))) {
die (sprintf("XML error: %s at line %d",
xml_error_strin g(xml_get_error _code
($xml_parser)),
xml_get_current _line_number
($xml_parser))) ;
}
}

fclose($fp);
xml_parser_free ($xml_parser);
}

parseRDF
("http://freshmeat.net/backend/fm-releases.rdf");
#("http://www.theregister .co.uk/headlines.rss") ;
?>

<br />
<h2>Latest Headlines From Newsforge</h2>
<?php
/* declare different RSS feed. Since the code to parse source is
* already listed, all one needs to do is list the new source as
* follows*/
parseRDF("http://www.newsforge.c om/newsvac.rss");

Replace the last line, with whatever source you wish to parse.

There are some varations out there, were one can cache the file in a dbase, so
that each time teh page is loaded it doesn't hit the remote server everytime.
But, I'll leave that as an exercise for you to find. ;)

HTH.

--
S.Allen
-------------------------------------------
barnyard Sunday Apr 25 2004 11:10:02 PM EDT
-------------------------------------------
Ver o que é justo e não agir com justiça é a maior das covardias
humanas.
-- Confúcio
Jul 17 '05 #4
In article <sl************ **@barnyard.swe etpig.dyndns.or g>, marathon wrote:
On Thu, 22 Apr 2004 23:15:41 +0200, Mayhem in comp.lang.php wrote:
I would like to integrate an RSS newsfeed into my website but can't
seem to figure out how.
Has anyone got any pointers for me?


I had the same issue a few weeks ago. Using Google, I found a snippet which I
adapted to my needs. Here's something you might be able to work with;


[snip code]

Or you could simply use the code at http://magpierss.sf.net
Jul 17 '05 #5
I set up an rss feed then documented exactly how I did it on this page:
http://www.yourweb.name/
It definitely isn't the only way or the best way, but it works.

Jul 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
5201
by: lawrence | last post by:
I wanted to test xml_parse_into_struct() so I took the example off of www.php.net and put this code up on a site: <?php $simple = <<<END <item>
2
2000
by: Charles Stricklin | last post by:
If I have an RSS newsfeed like this: <?xml version="1.0" encoding="utf-8"?><!-- generator="whocares" --> <rss version="0.92"> <channel> <title>Website Name</title> <link>http://www.websiteurl.com</link> <description>Description of website</description> <lastbuilddate>Sun, 19 Sep 2004 04:34:52 +0000</lastbuilddate> <docs>http://backend.userland.com/rss092</docs>
0
1146
by: Julian | last post by:
I have written a CGI program which takes an RSS feed and turns it into HTML. I'm using it to display the latest headlines from the BBC News website. The question is, what order should I display the items in? In the raw XML feed, the items are not in chronological order. I can sort the items into pubDate order, but then I notice the items are not shown in the same order as on the BBC website. What is the correct logic for determining...
1
1321
by: hp_1981 | last post by:
Hi My website is a web directory like dmoz and yahoo directory. Can I let webmasters or even weblog owners to have a copy of my site, allowing them to present it the way they want to, by providing rss links? Is rss a good solution? If so, I think I have two options:
1
1877
by: nostradamus | last post by:
Hi! We need to integrate an RSS feed in a webpage using ASP. I've been testing out the great script at ByteScout: http://bytescout.com/how_to_display_rss_using_asp.html It worked very well, but I couldn't make it work with feeds using Norwegian characters (æ, ø, å), e.g. Aftenposten:
6
2373
by: affiliateian | last post by:
Total newbie here for this so please be patient. We manually update our XML feed when we publish an article on our website. Can we add a javascript tracking pixel (from phpadsnew) into the XML file to track how many times our feed was accessed? Just to get a rough idea how manyh subscribers we have? Not sure if copying and pasting a javascript into the XML source would work.
0
1072
by: johndparker | last post by:
Hi, I have a ASP.NET web application I distribute precompiled (without source code) to clients. This can be run as a standalone web app but I would also like the option of the client integrating it into their ASP.NET web app so they both share the same ASP.NET Session. Does anyone know how this should be done? I've tried a few things: 1) Creating a new IIS virtual directory in the client's web site with my application installed...
1
1579
by: shotokan99 | last post by:
hi guys, i want to have rss on my site and the page is written in php (mypage.php). what are the things i need? how to start to with it? pls help.. tnx
10
2397
by: bhass | last post by:
From my other post I am making a simple program that creates an RSS feed with Python. Now when I run my program so far, I get errors. It says "something is not defined". The word something is replaced by the name of the function I'm trying to use. my article function when ran, comes up with "article is not defined" etc. Here's my code: What is wrong with it? #!/usr/bin/env python import ftplib import getpass def mainfeed(): ...
0
9642
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10780
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10497
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10539
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10212
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7753
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5623
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3968
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3077
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.