You will need to set the XML headers if you want to directly output the file:
Using Codeigniter Output Class :
$xml = $this->dbutil->xml_from_result($query, $config); $this->output->set_content_type('text/xml'); $this->output->set_output($xml);
Or you can use simple PHP to set the headers :
header('Content-type: text/xml'); echo $this->dbutil->xml_from_result($query, $config);
Or you can use the CI helper to download :
$xml = $this->dbutil->xml_from_result($query, $config); $this->load->helper('download'); force_download('myfile.xml', $xml);
Or write it to a file using the file assistant :
$xml = $this->dbutil->xml_from_result($query, $config); $this->load->helper('file'); $file_name = '/path/to/myfile.xml'; write_file($file_name, $xml);
Wesley murch
source share