Creating file .xml from rss?

#1
[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

#2
[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

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

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

#5
[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...

#6
[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?

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

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


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.