Trying to view a XML instead of PHP or HTML file |
[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
[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.
[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');
[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()); |
Welcome Guest, Not a member yet? Register Sign In |