brycenesbitt Posted May 19, 2011 Share Posted May 19, 2011 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 Link to comment https://forums.phpfreaks.com/topic/236888-tip-needed-how-to-stream-a-compressed-bz2bzip2gzip-file-through-xmlreader/ Share on other sites More sharing options...
requinix Posted May 19, 2011 Share Posted May 19, 2011 ->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. Link to comment https://forums.phpfreaks.com/topic/236888-tip-needed-how-to-stream-a-compressed-bz2bzip2gzip-file-through-xmlreader/#findComment-1217715 Share on other sites More sharing options...
brycenesbitt Posted May 19, 2011 Author Share Posted May 19, 2011 If the file was small, I would not be writing here. The file is far too big to uncompress. Link to comment https://forums.phpfreaks.com/topic/236888-tip-needed-how-to-stream-a-compressed-bz2bzip2gzip-file-through-xmlreader/#findComment-1217841 Share on other sites More sharing options...
requinix Posted May 19, 2011 Share Posted May 19, 2011 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 Link to comment https://forums.phpfreaks.com/topic/236888-tip-needed-how-to-stream-a-compressed-bz2bzip2gzip-file-through-xmlreader/#findComment-1217858 Share on other sites More sharing options...
btherl Posted May 20, 2011 Share Posted May 20, 2011 Using a named pipe is another possibility, for turning a stream into an openable file. But if the stream wrapper works, go with that. It's much simpler. Link to comment https://forums.phpfreaks.com/topic/236888-tip-needed-how-to-stream-a-compressed-bz2bzip2gzip-file-through-xmlreader/#findComment-1217859 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.