简体   繁体   English

在php和CodeIgniter中加载xml文件

[英]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. 我正在尝试在CodeIgniter中使用XML DOM,但是无法加载xml文档。 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: 我不确定我对CodeIgniter的理解是否足够好,但是我猜我如何写文件路径存在一些问题:

$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' '/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? 有人可以解释这些相对路径应该如何工作,而我需要做些什么才能加载xml文档?

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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