Log in

View Full Version : Trouble combining multiple RSS feeds into one feed



Spinethetic
06-03-2008, 10:14 PM
The problem I keep running into is that the final output does not validate. The three feeds are valid individually but not when a use my script:


<?php

$handle1 = fopen("rss_news.xml", "r");
$contents = stream_get_contents($handle1);
fclose($handle1);
echo $contents;

$handle2 = fopen("rss_articles.xml", "r");
$contents1 = stream_get_contents($handle2);
echo $contents1;
fclose($handle2);

$handle3 = fopen("rss_creativeart.xml", "r");
$contents2 = stream_get_contents($handle3);
echo $contents2;
fclose($handle3);

?>


And since it is not valid Feedburner will not accept it. http://validator.w3.org/feed/check.cgi?url=http%3A%2F%2Fintegralbuddha.net%2Frss.php

Spinethetic
06-04-2008, 03:41 PM
What I think is happening is that when all feeds are combined, the final output still retains all opening and closing <rss> and <channel> tags. So how would I go about omitting these tags dynamically so that my php would look something like


<?php
echo "<rss version='2.0' xmlns:atom='http://www.w3.org/2005/Atom'>";
echo "<channel>";

$handle1 = fopen("rss_news.xml", "r");
$contents = stream_get_contents($handle1);
echo $contents;
fclose($handle1);

$handle2 = fopen("rss_articles.xml", "r");
$contents1 = stream_get_contents($handle2);
echo $contents1;
fclose($handle2);

$handle3 = fopen("rss_creativeart.xml", "r");
$contents2 = stream_get_contents($handle3);
echo $contents2;
fclose($handle3);

echo "</channel>";
echo "</rss>";
?>