Jump to content

Tip needed: how to stream a compressed (bz2,bzip2,gzip) file through XMLReader


brycenesbitt

Recommended Posts

Is there a way I can readily stream-process a compressed XML file in PHP?  Something like this NON WORKING example:

$reader = new XMLReader();
$reader->open(bzopen($planet_file,"r"));
while ($reader->read()) {
...

See also http://php.net/manual/en/xmlreader.open.php

->open() takes a file location, not an open file handle.

 

If the file is small you could decompress it to memory and point XMLReader there. Otherwise you're probably stuck using temporary files.

Well then I'm glad I brought that up because otherwise I would never have known.

 

It occurs to me that you could use a stream wrapper.

$reader->open("compress.bzip2://$planet_file");

Compression streams

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.