CodeIgniter Forums
loading a view vs. loading a 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: loading a view vs. loading a file (/showthread.php?tid=22361)



loading a view vs. loading a file - El Forum - 09-06-2009

[eluser]neomech[/eluser]
Hi,

I'm trying to work with an xml file that I created. I was using simplexml_load_file (I've got PHP 5 installed) and was getting an error so I thought I'd use the CI load library functions.

If I try this in my controller:
Code:
xml=$this->load->file('../xml/filter.xml',TRUE);
I get an error: "Unable to load the requested file: filter.xml"

If I try this instead:
Code:
$xml=$this->load->view('../xml/filter.xml','',TRUE);
Everything seems to work.

Can anyone explain why either the simplexml call or the CI load->file call aren't working? It seems like the other two methods are looking for me to identify the directory differently.

If it matters, my directory structure is:

-application
--model
--view
--controller
--xml
-library
--system
-public_html
--images
--js
--css

I'm using the .htaccess file from the CI wiki (Elliot Haughin's)


loading a view vs. loading a file - El Forum - 09-06-2009

[eluser]richthegeek[/eluser]
load->file goes from the root directory (which contains system, user_guide, index.php etc) whilst load->view goes from application/views.


loading a view vs. loading a file - El Forum - 09-06-2009

[eluser]neomech[/eluser]
Ahh....awesome...everything works now. Thanks very much!