August 13, 200916 yr <?php echo '<?xml version="1.0" ?>'; echo '<rss version="2.0">'; echo '<channel>'; // Opens our main content echo '<title>Test Website RSS Feed</title>'; // Defines the title of the RSS feed echo '<link>http://www.testsite.com</link>'; // Where the RSS feed is from echo '<description>This RSS feed is all about the pie.</description>'; // What its about $c = mysqli_connect('localhost', '', '', '') or die(mysqli_error($c)); // Connect with our information $q = mysqli_query($c, 'SELECT * FROM news ORDER BY id DESC LIMIT 5') or die(mysqli_error($c)); // Query the table for 5 news articles sorting by 'id' while($r = mysqli_fetch_assoc($q)) // While there is more rows to get (max of 5) we get an associative array { echo '<item>'; // Begin a news article echo '<title>'.$r['title'].'</title>'; // Give it a title echo '<link>'.$r['permalink'].'</link>'; // The link to the article echo '<description>'.$r['content'].'</description>'; // The description or content of the article echo '<author>'.$r['author'].'</author>'; // The author echo '<pubDate>'.$r['date'].'</pubDate>'; // The date is was published echo '</item>'; // End news article } // End while statement echo '</channel>'; echo '</rss>'; /> im confused as when i load it up i get an error saying "XML Parsing Error: no element found Location: http://www.quad.co.uk/test1.xml Line Number 27, Column 3:?> --^" where could i be going wrong? thanks in advance
August 13, 200916 yr That links just redirects me to http://www.quad.co.uk - I can't see the actual XML file. But it sounds like your XML document isn't well-formed.
August 13, 200916 yr Author http://www.getrecognized.co.uk/test1.xml and well i used a tutorial so i dont understand why it doesnt work ? cheers
August 13, 200916 yr Have you seen the source code? When I load that page in Firefox - I get an error as you explained. And when I view the source I see the full PHP code. That tells me that PHP isn't enabled for your website.
August 13, 200916 yr Author thats because its a .xml file and not .php i have www.getrecognized.co.uk/test1.php also that shows some data but doesnt come up right confused
August 13, 200916 yr Two problems: 1) You've encoded all the angle brackets < and > as < and > 2) By default .PHP files are normally set up to be treated with text/html MIME type. Before you output any data - send an HTTP header to identify the document as RSS XML. header('Content-Type: application/rss+xml');
Create an account or sign in to comment