Many ways to do it; I am explaining the one I use.  I retrieve XML
based on extension.  So my URL looks like http://localhost/entries/index.xml

Here are my steps:

1. Add an XML directory under you views, for eg. in my case

app\views\entries\xml

2. Create an index.ctp with the following code

<?php echo $xml->serialize($entries);
?>

3. Make sure you have the following line in Routes.php

Router::parseExtensions();

4. Add RequestHandler component to your Controller

var $components = array(’RequestHandler’);

5. [optionally] I also modify the index function in my controller to
the following

function index() {
                $this->Entry->cacheSources = false;
                $this->Entry->recursive = 0;
                if ($this->params['url']['ext'] == 'html') {
                        $this->set('entries', $this->paginate());
                } else {
                        Configure::write('debug',0);
                        $this->set('entries', $this->Entry->find('all'));
                }
        }

To understand how all of this works, refer to
http://www.pagebakers.nl/2007/06/05/using-json-in-cakephp-12/


On Feb 10, 11:38 pm, Alfredo Quiroga-Villamil <[email protected]>
wrote:
> This should be simple, yet for some reason can't find how to do it.
>
> I need to render XML.
>
> What is the correct way to accomplish this?
>
> Thanks in advance,
>
> Alfredo
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to