CodeIgniter Forums
Creating file .xml from rss? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Creating file .xml from rss? (/showthread.php?tid=33701)



Creating file .xml from rss? - El Forum - 09-05-2010

[eluser]tnathos[/eluser]
Hi, i have a problem, in my site i have a feed rss and works fine.. in the controller i set the data and send to the view..

But i need call the .xml file so ho i can do?

for example:

http://mysite.com/feed -> works

i need -> http://mysite.com/feed.xml

TY


Creating file .xml from rss? - El Forum - 09-05-2010

[eluser]Bas Vermeulen[/eluser]
Hi,

Settings this in your application/config/routes.php should work:

Code:
$route['feed.xml'] = 'feed';

ps: don't forget to add the . to the $config['permitted_uri_chars'] @ application/config/config.php


Creating file .xml from rss? - El Forum - 09-05-2010

[eluser]tnathos[/eluser]
ok thabks i go to test


Creating file .xml from rss? - El Forum - 09-05-2010

[eluser]tnathos[/eluser]
ok but in this case i need get the response to the contoller "feed" and show using feed.xml..


Creating file .xml from rss? - El Forum - 09-05-2010

[eluser]Bas Vermeulen[/eluser]
If my solution does not achieve what you want to achieve than I don't really understand you. Please elaborate on your question...


Creating file .xml from rss? - El Forum - 09-05-2010

[eluser]tnathos[/eluser]
ok,

i have an controller named "feed" this controller response a rss. for example http://mysite/feed

Now i need get this response and shw using a file .xml for exmaple http://mysite/feed/rss.xml how i can create the file xml from the feed?


Creating file .xml from rss? - El Forum - 09-05-2010

[eluser]Bas Vermeulen[/eluser]
Oh you want the output to be XML?

Put this in your view, should work:
Code:
header("Content-Type: text/xml;charset=UTF-8");
    $sitemap = '<?xml version="1.0" encoding="UTF-8"?>
            <urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                    xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"
                    >
                <url>
                <loc>www.domain.tld/page</loc>
                <lastmod>2010-09-06</lastmod>
                <changefreq>daily</changefreq>
                <priority>0.8</priority>
                </url>
            </urlset>';
    echo $sitemap;

Your feed controller should pull the data from a model and send it to the view, in the view you can then populate the xml feed with a simple foreach looping through your data array.

I hope this does answer your question?


Creating file .xml from rss? - El Forum - 09-05-2010

[eluser]tnathos[/eluser]
thanks, i try test Smile