在 php 和 CodeIgniter 中加载 xml 文件
我正在尝试在 CodeIgniter 中使用 XML DOM,但无法加载 xml 文档。我不确定我对 CodeIgniter 的理解是否足够好,但我想我如何编写文件路径存在一些问题:
$xmlDoc = new DOMDocument();
$xmlDoc->load('filter.xml');
该文件与调用文件位于同一目录中。但这行不通。我还尝试过这样的路径变体:
'/application/models/filter.xml' base_url().'/application/models/filter.xml' base_url().'application/models/filter.xml'
但没有任何效果。有人可以解释一下这些相对路径应该如何工作,以及我需要做什么才能加载 xml 文档吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 realpath 来调试并了解 CodeIgniter 尝试在何处查找您的文件。
use realpath to debug and understand where CodeIgniter tries to find your file.