Load gzipped XML file with simplexml_load_file()

后端 未结 3 368
小蘑菇
小蘑菇 2020-12-11 08:00

I\'m trying to load a gzipped XML file using simplexml_load_file() PHP function, but I don\'t know how to decode it so I can use the data in it.

3条回答
  •  悲&欢浪女
    2020-12-11 08:43

    PHP has support for zlib compression build-in, just prefix the path of your file with the gzip'ed data with compress.zlib:// and you're done:

    $xml = simplexml_load_file("compress.zlib://test.xml");
    

    Works like a charm.

提交回复
热议问题