I transformed an XML to JSON, this is the link: https://api.myjson.com/bins/us5f4
I used a lot of CakePHP 3.30 and below Collection's functions. What I need to do is to only extract some data, for example the tag @INDICATOR and @TIME_PERIOD.
I already tried using nest, filter, append, map in collections and none of them work for some reason.
This is my controller:
<?php
namespace App\Controller;
use App\Controller\AppController;
use Cake\Collection\Collection;
use Cake\ORM\TableRegistry;
use Cake\Utility\Xml;
class BalancesFiscalesController extends AppController
{public function balancesDatos2(){
$xmlArray = Xml::toArray(Xml::build('webroot/e-ggds/BalanceFiscalGC.xml'));
$collection = new Collection($xmlArray);
$collection->nest('@INDICATOR', '[]')->toList(); //I tried with the parent "Series" still same problem. It returns me the whole JSON instead of what I need. I also tried filter, map, append, no luck.
//Gobierno Central
$response = [
'gob_central' =>[
'titulos' =>[
$collection
]
]
];
$this->set([
'data' => $response,
'_serialize' => ['data']
]);
}
}