在 php 和 CodeIgniter 中加载 xml 文件

发布于 2024-12-09 05:06:52 字数 417 浏览 2 评论 0原文

我正在尝试在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

有木有妳兜一样 2024-12-16 05:06:52

使用 realpath 来调试并了解 CodeIgniter 尝试在何处查找您的文件。

use realpath to debug and understand where CodeIgniter tries to find your file.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文