function GET() { //Search the text if (array_key_exists('q', $_GET)) { //'description LIKE \'%' + $_GET['q'] +'%\'' $data = $this->models['Location']->findAll(array('conditions' => 'description LIKE \'%' . $_GET['q'] . '%\'')); //$this->returnXML = false; } elseif (array_key_exists('id', $_GET)) { $data = $this->models['Location']->findAll(array('conditions' => 'id =' . $_GET['id'])); } else { $data = $this->models['Location']->findAll(); } $xml = new XMLAuthor(); $xml->push("locations"); if (count($data) > 0) { $keys = array_keys($data[0]); } foreach ($data as $row) { $xml->push('location'); //print_r($row); foreach ($keys as $k) { $xml->element($k, $row[$k]); } // $xml->element('id',$row['id']); // $xml->element('country_id', $row['country_id']); // $xml->element('region_id', $row['region_id']); // $xml->element('description',$row['description']); $xml->pop(); } $xml->pop(); return $xml->getXml(); }