Jump to content

Creating RSS Feeds From HTML Files Help (Code Included)


thesprucegoose

Recommended Posts

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?

 

<?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>

 

Thanks,

~TSG

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.