Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Work-around for bug in SourceForge blog RSS feeds. This code reads the SF feed, transforms it to fix the bug and emits the revised code as a fresh XML document. Fully described at
Fix for SF RSS feed bug:
Reads RSS source code from SourceForge and re-renders it, adding an
isPermaLink=false attribute to every <guid> tag.
class SFBlogFeedConverter {
private $feedURL; // URL of SourceForge RSS feed
private $rssDOM; // RSS DOM
public function __construct($feedURL) {
$this->rssDOM = new DOMDocument();
$this->feedURL = $feedURL;
public function RenderRSS() {
if ( !@$this->rssDOM->Load($this->feedURL)) {
$code = 500;
$desc = 'Internal Server Error';
header("HTTP/1.0 $code $desc");
header("Status: $code $desc");
header('Content-Type: text/html; charset=utf-8');
echo "<!DOCTYPE html>\n"
. "<html>\n"
. "<head>\n"
. "<meta charset=\"utf-8\">\n"
. "<title>$code $desc</title>\n"
. "</head>\n"
. "<body>\n"
. "<h1>$code $desc</h1>\n"
// Replace [PROJECT] below with the required project name
. "<p>Can''t open [PROJECT] blog feed on SourceForge</p>\n"
. "</body>\n"
. "</html>\n";
$guidNodes = $this->rssDOM->getElementsByTagName('guid');
foreach ($guidNodes as $guidNode) {
$guidNode->setAttribute('isPermaLink', 'false');
header('Content-Type: application/xml; charset=utf-8');
$xml = $this->rssDOM->saveXML();
header('Content-Length: ' . strlen($xml));
echo $xml;
$blogXML = new SFBlogFeedConverter(
// Replace [PROJECT] below with the required project name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.