我应该使用什么程序来制作一个 gzipped xml (xml.gz) 文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1253711/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What program should I use to make a gzipped xml (xml.gz) file?
提问by Brian Agnew
I really need help with finding a program which will allow me to edit xml.gzfiles. To be honest I'm not even sure what a xml.gzfile is for that matter. If it's a compressed xml file then I would also like to ask how to compress a xml file. So to sum it up I'd like to know some program suggestions and an explanation about xml.gzfiles.
我真的需要帮助找到一个允许我编辑xml.gz文件的程序。老实说,我什至不确定xml.gz文件是什么。如果是压缩的xml文件那我还想问一下如何压缩xml文件。总而言之,我想知道一些程序建议和有关xml.gz文件的解释。
回答by Brian Agnew
It's just a compressed .xml file. e.g. to create
它只是一个压缩的 .xml 文件。例如创建
gzip file.xml
which creates the file with the suffix .gz.
它创建后缀为.gz.
And to decompress
并解压
gunzip file.xml.gz
(The gzip utilities will likely be standard on your Unix, or they're available via Cygwinfor Windows).
(gzip 实用程序可能是您的 Unix 上的标准配置,或者它们可以通过Cygwinfor Windows 获得)。
Note that some editors will let you edit the .gzfile by uncompressing it on the fly for you, so you don't need to uncompress thenedit (e.g. vim)
请注意,某些编辑器会让您.gz通过即时解压缩文件来编辑文件,因此您无需解压缩然后编辑(例如vim)
回答by M.N
Create the XML file with any tool.
使用任何工具创建 XML 文件。
after that, if on Unix/Linux - you may use gzip:
之后,如果在 Unix/Linux 上 - 您可以使用gzip:
To compress
压缩
$gzip <path>/filename.xml
You will have the compressed filename.xml.gzin the same folder.
您将filename.xml.gz在同一文件夹中压缩。
To decompress
解压
$gzip -d <path>/filename.xml.gz
In case of windows, you may use 7zip
在 Windows 的情况下,您可以使用7zip
回答by Shawn Chin
(to nudge the thread programming-wards)
(轻推线程编程病房)
To read/write gzip files programatically, one could try the zlib library which enables read/write to gzip files using a similar interfaces to fopen/fwrite/fclose.
要以编程方式读/写 gzip 文件,可以尝试使用 zlib 库,该库使用与 fopen/fwrite/fclose 类似的接口启用对 gzip 文件的读/写。
http://www.zlib.net/manual.html#gzopen
http://www.zlib.net/manual.html#gzopen
In python, it's a lot simpler -- using the gzip module: http://www.doughellmann.com/PyMOTW/gzip/
在 python 中,它要简单得多——使用 gzip 模块:http: //www.doughellmann.com/PyMOTW/gzip/
回答by Alberto Zaccagni
From the entry in Wikipedia http://en.wikipedia.org/wiki/Gzip:
从维基百科的条目http://en.wikipedia.org/wiki/Gzip:
gzip is a software application used for file compression. gzip is short for GNU zip.
gzip 是用于文件压缩的软件应用程序。gzip 是 GNU zip 的缩写。
You can unzip the file with a proper tool depending on your operating system, edit your document, then compress it again.
您可以根据您的操作系统使用适当的工具解压缩文件,编辑您的文档,然后再次压缩它。
回答by Ulrik Rasmussen
You can find executables at http://www.gzip.org/
您可以在http://www.gzip.org/找到可执行文件
回答by Otto Allmendinger
You can uncompress an xml.gz file on a standard Linux distribution with the command
您可以使用以下命令在标准 Linux 发行版上解压缩 xml.gz 文件
gunzip file.xml.gz
And likewise compress it with the command
同样用命令压缩它
gzip file.xml
On windows you can use your favorite archive manager or use 7zipif you don't have one.
在 Windows 上,您可以使用您最喜欢的存档管理器,或者如果您没有,则使用7zip。

