我可以在 URL 上使用 simplexml_load_file 但如果我保存它,它不会加载
I can use simplexml_load_file on an URL but if I save it, it won't load
如果我使用 simplexml_load_file($URL)
加载文件,则文件加载没有问题。
但是,当我尝试从本地加载它时,使用:
simplexml_load_file(Storage::get('public/XML/myfile.xml'))
我收到错误:
simplexml_load_file(): I/O warning : failed to load external entity
该文件存在,作为 Storage::exists()
方法 returns true
如果我在 Artisan tinker 控制台中写入,Storage::get('public/XML/myfile.xml')
,该文件将被返回。
我正在使用以下方式保存我的文件:
Storage::put('public/XML/myfile.xml', file_get_contents($URL));
simplexml_load_file()
将 XML 文件(磁盘上的文件或 URL)解释为对象。
但在您的情况下,您希望将文件的内容 => XML 的字符串解释为一个对象,您可以使用 simplexml_load_string
simplexml_load_string(Storage::get('public/XML/myfile.xml'));
如果我使用 simplexml_load_file($URL)
加载文件,则文件加载没有问题。
但是,当我尝试从本地加载它时,使用:
simplexml_load_file(Storage::get('public/XML/myfile.xml'))
我收到错误:
simplexml_load_file(): I/O warning : failed to load external entity
该文件存在,作为 Storage::exists()
方法 returns true
如果我在 Artisan tinker 控制台中写入,Storage::get('public/XML/myfile.xml')
,该文件将被返回。
我正在使用以下方式保存我的文件:
Storage::put('public/XML/myfile.xml', file_get_contents($URL));
simplexml_load_file()
将 XML 文件(磁盘上的文件或 URL)解释为对象。
但在您的情况下,您希望将文件的内容 => XML 的字符串解释为一个对象,您可以使用 simplexml_load_string
simplexml_load_string(Storage::get('public/XML/myfile.xml'));