From: Robert Klemme Date: 2005-11-15T00:17:16+09:00 Subject: Re: trouble reading a gzipped xml-file Guido de Melo wrote: > Hi, > > I'm trying to read a gzipped xml-file into rexml, but I don't quite > succeed. Perhaps someone can help me. Till now I tried this: > > #!/usr/bin/ruby -w > > require 'zlib' > require 'rexml/document' > > Zlib::GzipReader.open('file.dia') {|gz| > print gz.read > } > # this prints everything nicely and it works > > f = Zlib::GzipReader.open("file.dia") > s = f.read > p s You're not closing f here. > # now the ungzipped contents are in s, they look like this however: > # "\n # xmlns:dia=\"http://www.lysator.liu.se/~alla/dia/\">\n > # \n \n > # all in one line and encapsulated in "" > # so of course the next command fails I'm not so sure that it fails just because of this. > xmldoc = REXML::Document.new s > p xmldoc > # gives: ... > > Any ideas on this? This can't be too difficult, I think... > Guido Did you try this? xmldoc = Zlib::GzipReader.open('file.dia') {|gz| REXML::Document.new gz} Kind regards robert