Hi, I am adapting a code that I had in pure PHP to Cakephp, but the problem that I found is the following: I had a file where I passed some records retrieved from a table to XML, this file was downloaded with JavaScript, using the function downloadUrl( ) this is to pass some data to the Google Maps API.
As I said in pure PHP works, the problem is that I do not know where to put this file in Cakephp As a view? As an element? And how do we call it from the downloadUrl() function? DownloadUrl(‘documentoxml’)?
documentoxml:
<!-- Start XML file, echo parent node -->
<?= '<documentos>'; ?>
<!-- Iterate through the rows, printing XML nodes for each -->
<?php foreach($documentos as $documento): ?>
<!-- ADD TO XML DOCUMENT NODE -->
<?= '<documento '; ?>
<?= 'id="'.$documento->id.'" '; ?>
<?= 'foto="'.$documento->imagen.'" '; ?>
<?= 'nombre="'.$documento->nombre.'" '; ?>
<?= 'texto="'.$documento->texto.'" '; ?>
<?= '</documento>'; ?>
<?php endforeach; ?>
<!-- End XML file -->
<?= '</documentos>'; ?>
Function downloadUrl( ):
downloadUrl("documentoxml", function(data) {
var xml = data.responseXML;
var documentoxml = xml.documentElement.getElementsByTagName('documentoxml');
......
}