我遇到了simplexml_load_file的问题。它没有从指定的路径加载xml文件。路径中存在文件。它在我的本地系统(Windows 7)中工作,但是当我在服务器系统上运行此命令时( linux)它没有用。
libxml_use_internal_errors(true);
$xml = simplexml_load_file($folder . $del_xml, 'SimpleXMLElement', LIBXML_PARSEHUGE);
if ( ! $xml)
{
Model_Log::error("Could not load XML file " . $folder .''. $del_xml);
}
else
{
Model_Log::info("File {$del_xml} loaded");
}
以下是xml。
<?xml version="1.0" encoding="UTF-16"?>
<products language="gb-en" xsi:noNamespaceSchemaLocation="test_brand.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:gdha.library="urn:gdha.library">
<product>
<product_category_hierarchy>
<parent_category>test</parent_category>
</product_category_hierarchy>
<product_content>
<basic_information>
<product_titles>
<short_title>title</short_title>
<long_title>title123</long_title>
</product_titles>
<product_descriptions>
<short_description>test</short_description>
<long_description>test 123</long_description>
</product_descriptions>
</basic_information>
</product_content>
</product>
</products>
答案 0 :(得分:0)
检查文件夹路径。你可能硬编码。 尝试 $ _SERVER [&#39; DOCUMENT_ROOT&#39;] 获得根路径。
检查您的文件名。 Windows服务器不区分大小写。但是linux区分大小写。
使用小写字母重命名文件。有些linux服务器会将文件名改为小写本身。因此,当您尝试从浏览器访问该文件时,将导致404错误。