简体   繁体   中英

Load xml file in php and CodeIgniter

I'm trying to use the XML DOM in CodeIgniter, but I can't load the xml document. I'm not sure I understand CodeIgniter well enough yet, but I guess there's some problem with how I write the path to the file:

$xmlDoc = new DOMDocument();
$xmlDoc->load('filter.xml');

The file is located in the same directory as the calling file. But this doesn't work. I have also tried variations of the path like this:

'/application/models/filter.xml' base_url().'/application/models/filter.xml' base_url().'application/models/filter.xml'

But nothing works. Could someone please explain how these relative paths should work, and what I need to do instead to be able to load the xml document?

使用realpath进行调试并了解CodeIgniter尝试在何处查找文件。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM