3

I have an xml file around 30 MB, which is distributed to client as Gzip Xml File through URL, but the problem is that as a Client, I can't save a copy of it into the client's server, as xml file.

When I try with SimpleXMLElement, it says that I have a problem on:

Request must contains the Accept-Encoding: gzip, deflate header

hakre
  • 193,403
  • 52
  • 435
  • 836
Erman Belegu
  • 4,074
  • 25
  • 39
  • Am I correct to assume you're doing something like this: `$xml = simplexml_load_file($someUrl);`? –  Sep 26 '12 at 17:52
  • I don't understand what your problem is? You are downloading a zip file and expecting it to be an XML file, its not, its a zip file. You must first unzip it before you can treat it as an XML file. – Toby Allen Sep 26 '12 at 18:01
  • 1
    Duplicate of http://stackoverflow.com/questions/4767734/open-remote-gzip-xml-file-for-use-with-simplexml First hit with google when looking for "simplexml gzip". – clentfort Sep 26 '12 at 18:29
  • Guys, read it carefully, it's not a ZIP, I never said ZIP, secondly, I did google, yahoo etc..didn't find there.. this was my last place at least for time being... – Erman Belegu Sep 26 '12 at 18:53
  • @rdlowrey no, I'm trying with SimpleXMLElement and it replies : Request must contains the Accept-Encoding: gzip, deflate header – Erman Belegu Sep 26 '12 at 18:55
  • 1
    @ErmanB -- *"trying with SimpleXMLElement"* ... this doesn't mean anything. I know what the problem is, but I can't help without seeing the code you're using to generate the error and/or the exact error message. –  Sep 26 '12 at 18:58
  • possible duplicate of [PHP open gzipped XML](http://stackoverflow.com/questions/1190906/php-open-gzipped-xml) – hakre Oct 22 '13 at 12:46

1 Answers1

3

You can tell PHP directly to uncompress from that URL so that you do not need to change headers in the HTTP stream wrapper context options:

$xml = simplexml_load_file("compress.zlib://http://site.com");
hakre
  • 193,403
  • 52
  • 435
  • 836
Ideal Bakija
  • 629
  • 5
  • 14