Ok, I have looked around, and I can't seem to figure this out.
Here is my CodeIgniter Structure:
As you can see, the XML folder is outside the application folder. Inside the XML folder I have an xml file named example.xml. Inside the controller, how do I load the xml file to view it in the browser?
class Example extends CI_Controller {
public function view_xml(){
header("Content-type: text/xml");
$this->load->view() ??????? // Here is where I'm stuck
}
}
I have tried using BASEPATH and $_SERVER['DOCUMENT_ROOT'] but with no luck. I want to be able to type in the url example/view_xml to view the xml in the browser.
Never mind, I figured it out. Instead of using CodeIgniter's $this->load->view(), I just load the file and echoed it out to the screen.
public function view_xml(){
header("Content-type: text/xml");
$xml_file = file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/xml/example.xml");
echo $xml_file;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With