Welcome to WebmasterWorld Guest from 18.104.22.168
Forum Moderators: phranque
So I'm looking for a small secure script that will pull the feed from my own directory, and embed the headlines into my own homepage.
I know that there are free proprietry *sites* that do this, but it seems daft to pull the feed from my directory to a server half a world a way, only to have it post the feed contents in a file back in my home directory.
I have MYSQL, but I'd prefer something that doesn't need it.
The best I could think was to use PHP5 but it's only just been released. The little I understand suggests this can pull xml + xslt and send the output to the user.
I'd look to write a simple XSLT stylesheet for the RSS and use PHP to do the work but this is not something I've tried before and may be dependant on your getting PHP5.. I've no idea whether PHP4 has XML handling.
Good luck.. I'd be interested to know of other approaches to this.
my $xmlfile = "example.xml";
my $xslfile = "example.xsl";
my $parser = XML::XSLT->new ($xslfile, "FILE");
$parser->transform_document ($xmlfile, "FILE");
Maybe that's all you need?
for a stylesheet you might use something like..
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<p><xsl:value-of select="description" disable-output-escaping="yes" /></p>
It goes wherever you want it and it's location is suggested by the my $xslfile = "example.xsl"; in the perl. So long as you get the relative location correct it should work.
The xml that the XSL stylesheet/transform works on is your RSS file.
If it does what we expect, the perl should call the XSL to transform the RSS file into HTML. ie. put your rss file location into my $xmlfile = "example.xml";
The transform I suggested is very simple but you can add other html elements to it. The XSL simply copies the HTML to output as it looks for "xsl:" elements.
<xsl:template match="item"> looks for all occurences of elements called 'item'
<xsl:template match="text()¦@*"> gives you control of the output by simply overwriting the default templates for text and attribute nodes. Otherwise you would get simple dump of the contents of nodes.
The only thing that might complicate this is if you are trying to add other <? scripting?> languages as the XSLT processor will try to understand the contents.. but then I believe there may be ways round that too.
Obviously you need to have the perl XML::XSLT module avaliable.
Hope that helps.
You can find more of an introduction to XML, XSL and others at w3schools [w3schools.com]
[edited by: davidpbrown at 9:10 am (utc) on July 16, 2004]
But my homepage is plain html, so I'm still scratchin' mi' bonce.
David, since you know more than I, why not try making a simple test rig to see if it works?
ie. Install the script and stylesheet, make a simple feed.xml file, and see if it displays in a .htm file on your site.