Creating RSS Feeds from HTML files. Help!
Posted: Thu Oct 30, 2008 2:33 pm
Hey,
I'm attempting to create a geoRSS feed by creating a parser that scans an image gallery and adds those images to an RSS Feed. The code below is what I have so far. When I run it, I get the following error:
Parse error: syntax error, unexpected T_VARIABLE in /home/content/n/k/8/nk86snyder/html/test_feed.php on line 14
The file test_feed.php is in the root directory.
Any ideas?
~TSG
I'm attempting to create a geoRSS feed by creating a parser that scans an image gallery and adds those images to an RSS Feed. The code below is what I have so far. When I run it, I get the following error:
Parse error: syntax error, unexpected T_VARIABLE in /home/content/n/k/8/nk86snyder/html/test_feed.php on line 14
The file test_feed.php is in the root directory.
Any ideas?
Code: Select all
<?php
class rss2 extends DomDocument {
private $channel;
public function __construct($title, $link, $description) {
parent::__construct();
$this->formatOutput = true;
$root = $this->appendChild($this->createElement('rss'));
$root->setAttribute('version', '2.0')
$channel = $root->appendChild($this->createElement('channel'));
$channel->appendChild($this->createElement('title', $title));
$channel->appendChild($this->createElement('link', $link));
$channel->appendChild($this->createElement('description', $description));
$this->channel = $channel;
}
public function addItem($title, $link, $description) {
$item = $this->createElemenet('item');
$item->appendChild($this->createElement('title', $title));
$item->appendChild($this->createElement('link', $link));
$item->appendChild($this->createElement('description', $description));
$this->channel->appendChild($item);
}
}
$rss = new rss2('Channel Title', 'http://digg.com', 'Channel Description');
$rss->addItem('Digg', 'http://digg.com/', 'Digg');
$rss->addItem('Digg Tech', 'http://digg.com/technology', 'Digg Tech');
print $rss->saveXML();
?>
<?xml version="1.0"?>
<rss version="2.0">
<channel>
<title>Testing The RSS</title>
<link>http://www.digg.com</link>
<description>Diggggggggg</description>
<item>
<title>Digg Technology</title>
<link>http://digg.com/technology</link>
<description>Digg Tech</description>
</item>
</channel>
</rss>