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 Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.