Reputation: 397
I would develop a service restful with cakephp 2.0 but I can't.
I receive this message after following the official documentation
The error message :
Warning (2): SimpleXMLElement::__construct() [simplexmlelement.--construct]: Entity: line 3: parser error : Extra content at the end of the document [CORE\Cake\Utility\Xml.php, line 177]
Warning (2): SimpleXMLElement::__construct() [simplexmlelement.--construct]: <response><Hotel><id>1041114</id><hotelFileName>Argana_Hotel</hotelFileName><hot [CORE\Cake\Utility\Xml.php, line 177]
Warning (2): SimpleXMLElement::__construct() [simplexmlelement.--construct]: ^ [CORE\Cake\Utility\Xml.php, line 177]
CakePHP: the rapid development php framework
String could not be parsed as XML
Error: An Internal Error Has Occurred.
Upvotes: 1
Views: 493
Reputation: 5208
Just ran into the same problem trying to implement RestKit from github.
Seems like the problem occurs when I pass multiple variables to the _serialize parameter.
Think it is because xml should be wrapped in a main container.
Nesting my content in a wrapper seemed to fix this error for me.
Broken Example:
<items>
<item>data</item>
<item>data</item>
<items>
<categories>
<category>data</category>
</categories>
Working Example:
<response>
<items>
<item>data</item>
<item>data</item>
<items>
<categories>
<category>data</category>
</categories>
</response>
Just changed:
$this->set('data', $this->viewVars);
$this->set('_serialize', array('data'));
To:
$this->set('data', array('data'=>$this->viewVars));
$this->set('_serialize', array('data'));
Upvotes: 1