I want to read data from XML file but it showing the following errors:
我想从XML文件中读取数据,但它显示以下错误:
Exception information: Message:simplexml_load_file(): I/O warning : failed to load external entity "/common/xml/demo.xml"
异常信息:消息:simplexml_load_file():I / O警告:无法加载外部实体“/common/xml/demo.xml”
Following is my code:
以下是我的代码:
public function init() {
require_once 'Zend/Config/Xml.php';
$xml = new Zend_Config_Xml('/common/xml/demo.xml');
echo $xml;
}
Any solutions...thanx
任何解决方案...... thanx
1 个解决方案
#1
1
It looks like you're trying to access /common/xml/demo.xml as an absolute path to a file. Do you have a /common directory in your root? Try getting rid of the first slash if what you mean is a relative path. If it's supposed to be a URL, add the full domain and http://...
看起来您正在尝试访问/common/xml/demo.xml作为文件的绝对路径。你的root中有/ common目录吗?如果您的意思是相对路径,请尝试删除第一个斜杠。如果它应该是一个URL,添加完整的域和http:// ...
If you really have a file with absolute /common/xml/demo.xml, you have to make sure apache has proper access permissions to that file at both a system file permission level and a apache configuration level (assuming you're not running this as a CLI script but serviing it as a site).
如果你真的有一个带有绝对/common/xml/demo.xml的文件,你必须确保apache在系统文件权限级别和apache配置级别对该文件具有适当的访问权限(假设你没有运行这个作为CLI脚本,但将其作为站点提供)。
#1
1
It looks like you're trying to access /common/xml/demo.xml as an absolute path to a file. Do you have a /common directory in your root? Try getting rid of the first slash if what you mean is a relative path. If it's supposed to be a URL, add the full domain and http://...
看起来您正在尝试访问/common/xml/demo.xml作为文件的绝对路径。你的root中有/ common目录吗?如果您的意思是相对路径,请尝试删除第一个斜杠。如果它应该是一个URL,添加完整的域和http:// ...
If you really have a file with absolute /common/xml/demo.xml, you have to make sure apache has proper access permissions to that file at both a system file permission level and a apache configuration level (assuming you're not running this as a CLI script but serviing it as a site).
如果你真的有一个带有绝对/common/xml/demo.xml的文件,你必须确保apache在系统文件权限级别和apache配置级别对该文件具有适当的访问权限(假设你没有运行这个作为CLI脚本,但将其作为站点提供)。