![]() |
Trying to view a XML instead of PHP or HTML file - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Trying to view a XML instead of PHP or HTML file (/showthread.php?tid=13510) |
Trying to view a XML instead of PHP or HTML file - El Forum - 11-25-2008 [eluser]Rubiz'[/eluser] Hello everyone :-) I'm trying to view a xml using $this->load->view('folder/test.xml'); I've tryied this too: echo $this->load->view('folder/test.xml'); but the XML really can't be read. CI does not support this kind of view? if dont't, how could I show this? Thanxs! RĂºbia Trying to view a XML instead of PHP or HTML file - El Forum - 11-25-2008 [eluser]iainco[/eluser] You could have your XML in a PHP file simply with no PHP code. Rename test.xml to test.php, then you can use the code Code: $xml = $this->load->view('folder/test', $data, TRUE); You might not need to pass any data to the view with the $data var. The last arg TRUE ensures the view contents are returned instead of being output to the browser. Trying to view a XML instead of PHP or HTML file - El Forum - 11-25-2008 [eluser]attos[/eluser] I use CI to provide a RSS feed using Derek Allard's tutorials. It's avalable from his site. I had an issue with the view with the closing xml tag. I had to replace it with Code: <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); Trying to view a XML instead of PHP or HTML file - El Forum - 11-26-2008 [eluser]Phil Sturgeon[/eluser] [quote author="attos" date="1227666792"]I use CI to provide a RSS feed using Derek Allard's tutorials. It's avalable from his site. I had an issue with the view with the closing xml tag. I had to replace it with Code: <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); Put the code above at the top of your view file, and add the following in your controller to set the headers correctly. Code: $this->output->set_header('Content-Type: text/xml; charset=ISO-8859-1'); Make sure that's done before your view file, and before any content is being output. If you do have anything being output, you'll need to clear the output buffer (wipe the screen), which can be done with: Code: while (@ob_end_clean()); |