Hi thanks for your advice.

I included

$this->layout='xml';

into my controller::index();

I place <?php echo $xml->header() ?> into the index.ctp.

But it is still not rendered as xml. I am using firefox and chrome.

any more idea why? or does anybody has a sample cakephp project with
REST.

On Jun 18, 1:31 am, John Andersen <j.andersen...@gmail.com> wrote:
> If I understand the XML helper correctly, then the result from the
> serialize method is an XML structure. But this structure is without
> the XML tag, so the browser will not see it as XML to be rendered.
>
> Somewhere there should be an XML layout that are used with outputing
> XML. In the layout should be the XML tag, I assume! :)
> Enjoy,
>    John
>
> On Jun 17, 4:33 pm, ytbryan <ytbr...@gmail.com> wrote:
>
> > Hi all,
>
> > I tried to follow this tutorial to do REST web services.
>
> > Below are my code.
>
> > CONFIG/ROUTES.PHP
> >         Router::mapResources('recipes');
> >         Router::parseExtensions('xml'); // it doesn't make a difference
> > whether i include 'xml' or not
>
> > MODEL
> > <?php
> > class Recipe extends AppModel {
> >         var $name = 'Recipe';}
>
> > ?>
>
> > VIEW //views/recipes/xml/index.ctp
>
> > <recipes>
> >         <?php echo $xml->serialize($recipes); ?>
> > </recipes>
>
> > CONTROLLER
> > <?php
> > class RecipesController extends AppController {
>
> >         var $name = 'Recipes';
> >     var $components = array('RequestHandler');
> >         var $helpers =array('Xml');
>
> >         function index() {
>
> >                 $recipes = $this->Recipe->find('all');
> >                 $this->set(compact('recipes'));
>
> >                 // $this->Recipe->recursive = 0;
> >                 // $this->set('recipes', $this->paginate());
> >         }
>
> > }
>
> > ?>
>
> > However, the xml is not rendered. But when i view source, it is there.
> > Is there a problem?
> > I test it on firefox, chrome and safari on macosx 10.6
>
>

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to