Wednesday, October 27, 2010

Re: XML output

Never mind, found it.. turning debug off really helps, it appears.

-- joe.


On Oct 27, 11:29 am, joe_90 <joe.warren.me...@gmail.com> wrote:
> Hey guys,
>
> I'm trying to get a REST app working using Cake and I've followed the
> instructions inhttp://book.cakephp.org/view/1473/XMLseveral times.
>
> I've added the following to config/routes.php:
>
>         Router::mapResources('shows');
>         Router::parseExtensions();
>
> My controller (just a stub) is as follows:
>
> <?php
> class ShowsController extends AppController {
>
>         var $name = 'Shows';
>         var $helpers = array('Html', 'Form', 'Xml');
>         var $components = array('RequestHandler');
>
>         function index() {
>                 $this->Show->recursive = 0;
>                 $this->set('shows', $this->paginate());
>         }
>
> }
>
> ?>
>
> and I have this in views/shows/xml/index.ctp:
>
> <shows>
> <?php
> echo $xml->serialize($shows);
> ?>
> </shows>
>
> Now, when I request shows/index.xml I get the following:
>
> joe@cadmus-db:~$ telnet localhost 80
> Trying ::1...
> Trying 127.0.0.1...
> Connected to localhost.
> Escape character is '^]'.
> GET /cadmus/shows.xml HTTP/1.1
> host: cadmus-db.dev.encoretix.co.uk
> Accept: application/xml
>
> HTTP/1.1 200 OK
> Date: Wed, 27 Oct 2010 10:26:55 GMT
> Server: Apache/2.2.14 (Ubuntu)
> X-Powered-By: PHP/5.3.2-1ubuntu4.5
> Set-Cookie: CAKEPHP=v100uifmkvunqqa4fs1itj6f20; path=/cadmus
> P3P: CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"
> Vary: Accept-Encoding
> Content-Length: 1134
> Content-Type: text/html
>
> <?xml version="1.0" encoding="UTF-8" ?><shows>
> <show ShoId="100" ShoName="Show A" /><show ShoId="101" ShoName="Show
> B" /><show ShoId="102" ShoName="Show C" /></shows>
>
> <!-- 0.1288s --><table class="cake-sql-log"
> id="cakeSqlLog_12881752154cc7fe6f7ef691_14197311" summary="Cake SQL
> Log" cellspacing="0" border = "0">
> <caption>(default) 3 queries took 0 ms</caption>
> <thead>
> <tr><th>Nr</th><th>Query</th><th>Error</th><th>Affected</th><th>Num.
> rows</th><th>Took (ms)</th></tr>
> </thead>
> <tbody>
> <tr><td>1</td><td>DESCRIBE `shows`</td><td></td><td style = "text-
> align: right">2</td><td style = "text-align: right">2</td><td style =
> "text-align: right">0</td></tr>
> <tr><td>2</td><td>SELECT COUNT(*) AS `count` FROM `shows` AS `Show`
> WHERE 1 = 1   </td><td></td><td style = "text-align: right">1</td><td
> style = "text-align: right">1</td><td style = "text-align: right">0</
> td></tr>
> <tr><td>3</td><td>SELECT `Show`.`ShoId`, `Show`.`ShoName` FROM `shows`
> AS `Show`   WHERE 1 = 1    LIMIT 20</td><td></td><td style = "text-
> align: right">3</td><td style = "text-align: right">3</td><td style =
> "text-align: right">0</td></tr>
> </tbody></table>
> Connection closed by foreign host.
>
> How can I stop Cake sending it as type text/html with all the html
> footers?
>
> It's driving me nuts..
>
> Cheers.
>
>  -- joe.

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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: