Re: XML output

2015-07-13 Thread John Andersen
Take a look in the CakePHP book 2.x at this location 
http://book.cakephp.org/2.0/en/views/json-and-xml-views.html#using-a-data-view-with-view-files

The solution is written in the "class XmlView" section :)

Enjoy, John

On Tuesday, 30 June 2015 16:43:25 UTC+3, Juan Ezquerro LLanes wrote:
>
> I'm using cake 2.x, how can i use _rootNode for custom xml output?
>
> I would like to delete the  labels.
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


XML output

2015-06-30 Thread Juan Ezquerro LLanes
I'm using cake 2.x, how can i use _rootNode for custom xml output?

I would like to delete the  labels.

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: Format my XML output in CakePHP

2013-02-05 Thread Rafael Rabelo
It's not that simple. Even though the array is changed, will still give 
something like:

 
 
   2
   Ciro
   Spee
  

  3  Ugo  
Ridi



I have the same problem. So I tried to isolate the problem, and I think it 
is on the array returned by the Model class.

The array returned by the function find is:

array(
(int) 0 => array(
'Project' => array(
'id' => '1'
)
),
(int) 1 => array(
'Project' => array(
'id' => '2',
)
)
)

And the one which is cited in the documentation for XML 
(http://book.cakephp.org/2.0/en/core-utility-libraries/xml.html#transforming-an-array-into-a-string-of-xml)
 
is:

array(
'projects' => array(
'project' => array(
(int) 0 => array(
'id' => (int) 1
),
(int) 1 => array(
'id' => (int) 2
)
)
)
)


Even after the XmlView._serialize() insert the  and "" 
nodes, still have differences.

I'm using the 2.3.0 version, and there is no issue about this 
on http://cakephp.lighthouseapp.com/dashboard

This is really a problem?


Em quarta-feira, 23 de janeiro de 2013 22h26min36s UTC-2, jsundquist 
escreveu:
>
> Change your set array to be players instead of output.
> On Jan 23, 2013 6:01 PM, "Mariano C." > 
> wrote:
>
>> I have the players table with three field id, first_name, last_name. The
>> PlayersController have method index that show every player in the table:
>>
>> public function index() {
>> $output = $this->Player->find('all');
>> $this->set(array(
>> 'output' => $output,
>> '_serialize' => array('output')
>> ));
>> $this->render('generic_response');
>> }
>>
>> and the generic_response is an XML view that look like this:
>>
>> > $xml = Xml::fromArray(array('response' => $output));
>> echo $xml->asXML();
>>
>> The resulting XML is:
>>
>> 
>>   
>>  
>>2
>>Ciro
>>Spee
>>  
>>
>>
>>  
>>3
>>Ugo
>>Ridi
>>  
>>
>>
>> but I want something like:
>>
>> 
>>   
>>  
>>2
>>Ciro
>>Spee
>>  
>>  
>>3
>>Ugo
>>Ridi
>>  
>>
>>
>> How can I do this?
>>
>> -- 
>> Like Us on FaceBook https://www.facebook.com/CakePHP
>> Find us on Twitter http://twitter.com/CakePHP
>>  
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "CakePHP" group.
>> To post to this group, send email to cake...@googlegroups.com
>> .
>> To unsubscribe from this group, send email to 
>> cake-php+u...@googlegroups.com .
>> Visit this group at http://groups.google.com/group/cake-php?hl=en.
>>  
>>  
>>
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

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




Re: Format my XML output in CakePHP

2013-01-23 Thread Jonathan Sundquist
Change your set array to be players instead of output.
On Jan 23, 2013 6:01 PM, "Mariano C."  wrote:

> I have the players table with three field id, first_name, last_name. The
> PlayersController have method index that show every player in the table:
>
> public function index() {
> $output = $this->Player->find('all');
> $this->set(array(
> 'output' => $output,
> '_serialize' => array('output')
> ));
> $this->render('generic_response');
> }
>
> and the generic_response is an XML view that look like this:
>
>  $xml = Xml::fromArray(array('response' => $output));
> echo $xml->asXML();
>
> The resulting XML is:
>
> 
>   
>  
>2
>Ciro
>Spee
>  
>
>
>  
>3
>Ugo
>Ridi
>  
>
>
> but I want something like:
>
> 
>   
>  
>2
>Ciro
>Spee
>  
>  
>3
>Ugo
>Ridi
>  
>
>
> How can I do this?
>
> --
> Like Us on FaceBook https://www.facebook.com/CakePHP
> Find us on Twitter http://twitter.com/CakePHP
>
> ---
> 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.
> Visit this group at http://groups.google.com/group/cake-php?hl=en.
>
>
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
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.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Format my XML output in CakePHP

2013-01-23 Thread Mariano C.


I have the players table with three field id, first_name, last_name. The
PlayersController have method index that show every player in the table:

public function index() {
$output = $this->Player->find('all');
$this->set(array(
'output' => $output,
'_serialize' => array('output')
));
$this->render('generic_response');
}

and the generic_response is an XML view that look like this:

 $output));
echo $xml->asXML();

The resulting XML is:


  
 
   2
   Ciro
   Spee
 
   
   
 
   3
   Ugo
   Ridi
 
   

but I want something like:


  
 
   2
   Ciro
   Spee
 
 
   3
   Ugo
   Ridi
 
   

How can I do this?

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
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.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Re: XML output

2010-10-27 Thread Jonathan Sibley
Ahh, glad you solved the problem.  Just so you know, knowing this will
also help someone else in the future.  Namely, me!  So thanks.

On Oct 27, 10:16 am, joe_90  wrote:
> Never mind, found it.. turning debug off really helps, it appears.
>
>  -- joe.
>
> On Oct 27, 11:29 am, joe_90  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/XMLseveraltimes.
>
> > I've added the following to config/routes.php:
>
> >         Router::mapResources('shows');
> >         Router::parseExtensions();
>
> > My controller (just a stub) is as follows:
>
> >  > 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:
>
> > 
> >  > echo $xml->serialize($shows);
> > ?>
> > 
>
> > Now, when I request shows/index.xml I get the following:
>
> > j...@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
>
> > 
> > 
>
> >  > id="cakeSqlLog_12881752154cc7fe6f7ef691_14197311" summary="Cake SQL
> > Log" cellspacing="0" border = "0">
> > (default) 3 queries took 0 ms
> > 
> > NrQueryErrorAffectedNum.
> > rowsTook (ms)
> > 
> > 
> > 1DESCRIBE `shows`22 > "text-align: right">0
> > 2SELECT COUNT(*) AS `count` FROM `shows` AS `Show`
> > WHERE 1 = 1   1 > style = "text-align: right">10 > td>
> > 3SELECT `Show`.`ShoId`, `Show`.`ShoName` FROM `shows`
> > AS `Show`   WHERE 1 = 1    LIMIT 2033 > "text-align: right">0
> > 
> > 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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: XML output

2010-10-27 Thread joe_90

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

 -- joe.


On Oct 27, 11:29 am, joe_90  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:
>
>  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:
>
> 
>  echo $xml->serialize($shows);
> ?>
> 
>
> Now, when I request shows/index.xml I get the following:
>
> j...@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
>
> 
> 
>
>  id="cakeSqlLog_12881752154cc7fe6f7ef691_14197311" summary="Cake SQL
> Log" cellspacing="0" border = "0">
> (default) 3 queries took 0 ms
> 
> NrQueryErrorAffectedNum.
> rowsTook (ms)
> 
> 
> 1DESCRIBE `shows`22 "text-align: right">0
> 2SELECT COUNT(*) AS `count` FROM `shows` AS `Show`
> WHERE 1 = 1   1 style = "text-align: right">10 td>
> 3SELECT `Show`.`ShoId`, `Show`.`ShoName` FROM `shows`
> AS `Show`   WHERE 1 = 1    LIMIT 2033 "text-align: right">0
> 
> 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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


XML output

2010-10-27 Thread joe_90
Hey guys,

I'm trying to get a REST app working using Cake and I've followed the
instructions in http://book.cakephp.org/view/1473/XML several times.

I've added the following to config/routes.php:

Router::mapResources('shows');
Router::parseExtensions();

My controller (just a stub) is as follows:

Show->recursive = 0;
$this->set('shows', $this->paginate());
}

}
?>


and I have this in views/shows/xml/index.ctp:



serialize($shows);
?>



Now, when I request shows/index.xml I get the following:

j...@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





(default) 3 queries took 0 ms

NrQueryErrorAffectedNum.
rowsTook (ms)


1DESCRIBE `shows`220
2SELECT COUNT(*) AS `count` FROM `shows` AS `Show`
WHERE 1 = 1   110
3SELECT `Show`.`ShoId`, `Show`.`ShoName` FROM `shows`
AS `Show`   WHERE 1 = 1LIMIT 20330

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


Re: XML Output

2010-04-16 Thread Jeremy Burns
Any takers please?

Jeremy Burns
jeremybu...@me.com
On 15 Apr 2010, at 16:45, Jeremy Burns wrote:

> I have a controller function that calls a model function that
> generates a well formed array. I want to convert the array to XML and
> submit it to a web service. The array is in the same shape as the
> example in the guide:
> Array
> (
>[Baker] => Array
>(
>[0] => Array
>(
>[name] => The Baker
>[weight] => heavy
>)
>[1] => Array
>(
>[name] => The Cook
>[weight] => light-weight
>)
>)
> )
> 
> The guide then tells me to:
> pr($xml->serialize($data));
> 
> This isn't rendering anything either via a view or debugging in the
> controller/model. I have declared the Xml helper in the controller.
> What am I doing wrong?
> 
> Secondly, whilst it's useful to push it to a view for testing purposes
> I really want to do something with it in the controller. How do I get
> an XML file there? Are there any good tutorials anywhere? (!.3 RC3).
> 
> 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
> 
> To unsubscribe, reply using "remove me" as the subject.

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


XML Output

2010-04-15 Thread Jeremy Burns
I have a controller function that calls a model function that
generates a well formed array. I want to convert the array to XML and
submit it to a web service. The array is in the same shape as the
example in the guide:
Array
(
[Baker] => Array
(
[0] => Array
(
[name] => The Baker
[weight] => heavy
)
[1] => Array
(
[name] => The Cook
[weight] => light-weight
)
)
)

The guide then tells me to:
pr($xml->serialize($data));

This isn't rendering anything either via a view or debugging in the
controller/model. I have declared the Xml helper in the controller.
What am I doing wrong?

Secondly, whilst it's useful to push it to a view for testing purposes
I really want to do something with it in the controller. How do I get
an XML file there? Are there any good tutorials anywhere? (!.3 RC3).

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

To unsubscribe, reply using "remove me" as the subject.


Re: XML output from cake controller/view

2007-04-02 Thread Jeremy Pointer

digital spaghetti wrote:
> Instead of your method, check out this tutorial:
>
> http://bakery.cakephp.org/articles/view/2
>
> Its an old article, but still works perfectly in Cake 1.2
>   
I had already tried that method i.e. created an xml layout with just 
header() and print("?xml but I was still getting the space all that 
example does is move the output from the view to layout+view.
As it happens a new day brought an answer I simply removed the 
 part from the output and problem solved, I'd still like to 
know where the space is coming from though.
> Tane
>
> On 4/2/07, Jeremy Pointer <[EMAIL PROTECTED]> wrote:
>   
>> I'm trying to output an xml document but I seem to be getting a space
>> character just before > receiving the data (not mine) to cough and splutter and die.
>>
>> In my controller I am setting $this->layout=false; and my view is:
>> > header("Content-type:text/xml");
>> print ("");
>> print("");
>> foreach ($rows as $row) print("".$row['table']['field']."");
>> print("");
>> ?>
>>
>> DEBUG is 0 I also tried removing all beforeFilter and beforeRender
>> settings in app_controller and the controller that calls this with no luck.
>>
>> Any ideas why I am getting a space, is there a different/better way to
>> output XML.
>>
>> --
>> */Jeremy Pointer/*
>> [EMAIL PROTECTED] 
>>
>> 
>
> >   


-- 
*/Jeremy Pointer/*
[EMAIL PROTECTED] 

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: XML output from cake controller/view

2007-04-02 Thread digital spaghetti

Instead of your method, check out this tutorial:

http://bakery.cakephp.org/articles/view/2

Its an old article, but still works perfectly in Cake 1.2

Tane

On 4/2/07, Jeremy Pointer <[EMAIL PROTECTED]> wrote:
>
> I'm trying to output an xml document but I seem to be getting a space
> character just before  receiving the data (not mine) to cough and splutter and die.
>
> In my controller I am setting $this->layout=false; and my view is:
>  header("Content-type:text/xml");
> print ("");
> print("");
> foreach ($rows as $row) print("".$row['table']['field']."");
> print("");
> ?>
>
> DEBUG is 0 I also tried removing all beforeFilter and beforeRender
> settings in app_controller and the controller that calls this with no luck.
>
> Any ideas why I am getting a space, is there a different/better way to
> output XML.
>
> --
> */Jeremy Pointer/*
> [EMAIL PROTECTED] 
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



XML output from cake controller/view

2007-04-02 Thread Jeremy Pointer

I'm trying to output an xml document but I seem to be getting a space 
character just before layout=false; and my view is:
");
print("");
foreach ($rows as $row) print("".$row['table']['field']."");
print("");
?>

DEBUG is 0 I also tried removing all beforeFilter and beforeRender 
settings in app_controller and the controller that calls this with no luck.

Any ideas why I am getting a space, is there a different/better way to 
output XML.

-- 
*/Jeremy Pointer/*
[EMAIL PROTECTED] 

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---