0

I was wondering if there is a way to parse a zipped xml file such as example.xml.gz with jQuery on the fly?

The reason is the file is huge and effects the performance if we call a request to the unzipped file. Any tips?

digitup
  • 529
  • 1
  • 6
  • 18
  • 1
    You can also convert XML to JSON to make it smaller (will work fine if tags consume more space than data). – Iarek Feb 27 '12 at 13:55

3 Answers3

2

You could let the browser handle the decompression.

Browsers support Content-Encoding = gzip, which does the gzipping "transparently" at the server/client level.

You can serve pre-gzipped data from a file (your example.xml.gz) as well, this just requires some configuration to make the server send the header and send the data as-is, not trying to recompress it.

AKX
  • 93,995
  • 11
  • 81
  • 98
  • Thank you so much: can you please provide an example? – digitup Feb 27 '12 at 09:25
  • For a configuration example on Apache, this seems relevant: http://feeding.cloud.geek.nz/2011/01/serving-pre-compressed-files-using.html – AKX Feb 27 '12 at 10:40
0

I'm not really sure using a compressed xml is the right way here. Javascript need the uncompressed file to parse it so Javascript must uncompress your file first and you lost the interest of using compressed file. Maybe it's better to use an uncompressed XML and set your server to use compression on data transfer (if the transfer is the pb why you want compressed xml).

Clawfire
  • 461
  • 1
  • 6
  • 14
  • The problem is that we get the file's update on weekly basis from the vendor compressed and when we tried with the uncompressed version, we noticed the request is consuming a lot of memory and takes long time to present the data. I have to mention the file is almost 5 mb. – digitup Feb 27 '12 at 09:24
0

JQuery is mainly a DOM manipulation library and is not suited for handling binary file formats.

Can't you just digest the xml server-side and only serve what's needed client-side?

Sander Versluys
  • 67,197
  • 23
  • 79
  • 89