I'd like to transform this given array
array(
'podcast' => array(
(int) 0 => array(
'Podcast' => array(
'id' => '2',
'xmlurl' => 'http://test2.com'
)
),
(int) 1 => array(
'Podcast' => array(
'id' => '4',
'xmlurl' => 'http://test4.com'
)
)
)
)
into this String with CakePHP 2.3.6:
<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
<opml version="2.0">
<head></head>
<body>
<outline xmlUrl="http://test2.com" />
<outline xmlUrl="http://test4.com" />
</body>
</opml>
How would I do this? I know there is a Doc here, but I would appreciate help nevertheless.
This is what I have so far:
$new = array();
foreach($podcasts as $p):
$pod['xmlurl'] = $p['Podcast']['xmlurl'];
endforeach;
$new['opml']['body']['outline'][]=$pod;
debug($new);
$xmlObject = Xml::fromArray($new);
$xmlString = $xmlObject->asXML();
debug($xmlString);
Output debug($xmlString):
'<?xml version="1.0" encoding="UTF-8"?>
<opml>
<body>
<outline>
<xmlurl>http://test1.com</xmlurl>
</outline>
</body>
</opml>'