G
Guido de Melo
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
# now the ungzipped contents are in s, they look like this however:
# "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<dia:diagram
# xmlns:dia=\"http://www.lysator.liu.se/~alla/dia/\">\n
# <dia:diagramdata>\n <dia:attribute name=\"background\">\n
# all in one line and encapsulated in ""
# so of course the next command fails
xmldoc = REXML:ocument.new s
p xmldoc
# gives: <UNDEFINED> ... </>
Any ideas on this? This can't be too difficult, I think...
Guido
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
# now the ungzipped contents are in s, they look like this however:
# "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<dia:diagram
# xmlns:dia=\"http://www.lysator.liu.se/~alla/dia/\">\n
# <dia:diagramdata>\n <dia:attribute name=\"background\">\n
# all in one line and encapsulated in ""
# so of course the next command fails
xmldoc = REXML:ocument.new s
p xmldoc
# gives: <UNDEFINED> ... </>
Any ideas on this? This can't be too difficult, I think...
Guido