2014-09-01 87 views
-1

我尝试打开一个XML,它位于MySQL数据库中。字段的类型是“LONGBLOB”的,但我得到了以下错误:从PHP打开XML文件

Warning: simplexml_load_file(): I/O warning : failed to load external entity "<?xml version="1.0" encoding="utf-8"?><cfdi:Comprobante xmlns:cfdi="http://www.sat.gob.mx/cfd/3" 

我的代码:

public function select(){ 
       $this -> conect = new conect("root", "...."); 
       $data = $this -> conect -> conexion();   
       $dbquery = $data -> prepare("SELECT * 
              FROM FILE 
              ORDER BY ID 
              LIMIT 1 
              "); 
       $dbquery -> execute();  
       $rows = $dbquery->fetch(PDO::FETCH_ASSOC); 
       $string = $rows['BYTES']; 

       $stream = fopen('php://memory','r+'); 
       fwrite($stream, $string); 
       rewind($stream); 

       echo stream_get_contents($stream); 

      } 
     } 

回答

0

如果你看看你看到documentationsimplexml_load_file()需要一个文件为参数并尝试打开该文件。它确实不是直接接受xml负载。

最简单的就是用流来解决这个问题。

+0

非常感谢您的回答,但您会为此推荐吗? – 2014-09-01 17:00:16

+0

那么,如所写:看看溪流。也许有一个开始,这应该给你的想法:http://evertpot.com/222/ – arkascha 2014-09-01 17:04:40

+0

我看我的升级,我错了?对不起,我是一个新手...... :( – 2014-09-01 17:53:57