I’m using this code in Codeigniter to generate XML:
public function get_cuisine()
{
$this->load->dbutil();
$sql = "select * from cuisine";
$query = $this->db->query($sql);
$config = array (
'root' => 'root',
'element' => 'element',
'newline' => "\n",
'tab' => "\t"
);
echo $this->dbutil->xml_from_result($query, $config);
}
But this shows the general print format. How can I get it to show as an XML type page?
You’ll need to set XML headers if you want to output the file directly:
Using the Codeigniter Output class:
Or you can use plain PHP to set the headers:
Or you can use the CI download helper:
Or write it to a file with the file helper: