cakephp 2 rest replication of tags

cocontamau

New Member
I would like to develop a rest API with cakephp.I do the following steps but I found that my xml response contain replication of a tag.Here is the code: \[code\]public function index() { $this->set('hotels', $this->Hotel->find('all'));}\[/code\]in xml/index.ctp\[code\]<?php $xml = Xml::build(array('results' => array('hotels' => $hotels))); echo $xml->saveXML();\[/code\]but when it sends a request the response look like this\[code\]<results> <hotels> <hotel> <id>1</id> <name>name</name> <hotel> </hotels> <hotels> <hotel> <id>2</id> <name>name2</name> <hotel> </hotels><results>\[/code\]But I want the response to be like this\[code\] <hotels> <hotel> <id>1</id> <name>name</name> <hotel> <hotel> <id>2</id> <name>name2</name> <hotel> <hotels>\[/code\]
 
Back
Top