PHP open gzipped XML

后端 未结 3 1363
清歌不尽
清歌不尽 2020-12-09 06:03

I am struggling to read gzipped xml files in php.

I did succeed in reading normal xml files, using XMLReader() like this:

$xml = new XMLReader();
$xm         


        
3条回答
  •  独厮守ぢ
    2020-12-09 06:45

    Expanding on Pascal's post, here is some example code that should work for you

    $xmlfile = fopen($linkToXmlFile,'rb');
    $compressedXml = fread($xmlfile, filesize($linkToXmlFile));
    fclose($xmlfile);
    $uncompressedXml = gzdecode($compressedXml); 
    
    $xml = new XMLReader();
    $xml->xml($uncompressedXml);
    

提交回复
热议问题