F
Frederic Logier
I have some problem with rexml. I want to use the stream parsing mode,
from an http_connect.get source.
Trouble is with a bad xml, which contains badly utf8 character.
When i open this xml from a local file, the stream parsing stop when it
encounter a bad ut8 character. It's exactly what i want.
But when i open this xml file from a Net::HTTP source, stream parsing
failed directly on utf8 error :
(eval):2:in `iconv': "\300\314\346\216\251 \346\215\256\307\337\346\217
\256 \300"... (Iconv::IllegalSequence)
from (eval):2:in `decode'
from /usr/lib/ruby/1.8/rexml/source.rb:43:in `encoding='
from /usr/lib/ruby/1.8/rexml/parsers/baseparser.rb:202:in `pull'
from /usr/lib/ruby/1.8/rexml/parsers/streamparser.rb:16:in
`parse'
from /usr/lib/ruby/1.8/rexml/document.rb:171:in `parse_stream'
from test_stream_rexml_yp.rb:29
here my source code :
#!/bin/ruby
require 'net/http'
require "rexml/document"
require "rexml/streamlistener"
include REXML
class Handler
include StreamListener
def tag_start name, attrs
if name=="channel"
puts attrs["name"]
end
end
end
http_connect = Net::HTTP.new("taonix.net", 80)
resp, data = http_connect.get("/files/yp_bug2.xml", nil )
Document.parse_stream(data, Handler.new)
#Document.parse_stream((File.new "yp_bug2.xml"), Handler.new)
from an http_connect.get source.
Trouble is with a bad xml, which contains badly utf8 character.
When i open this xml from a local file, the stream parsing stop when it
encounter a bad ut8 character. It's exactly what i want.
But when i open this xml file from a Net::HTTP source, stream parsing
failed directly on utf8 error :
(eval):2:in `iconv': "\300\314\346\216\251 \346\215\256\307\337\346\217
\256 \300"... (Iconv::IllegalSequence)
from (eval):2:in `decode'
from /usr/lib/ruby/1.8/rexml/source.rb:43:in `encoding='
from /usr/lib/ruby/1.8/rexml/parsers/baseparser.rb:202:in `pull'
from /usr/lib/ruby/1.8/rexml/parsers/streamparser.rb:16:in
`parse'
from /usr/lib/ruby/1.8/rexml/document.rb:171:in `parse_stream'
from test_stream_rexml_yp.rb:29
here my source code :
#!/bin/ruby
require 'net/http'
require "rexml/document"
require "rexml/streamlistener"
include REXML
class Handler
include StreamListener
def tag_start name, attrs
if name=="channel"
puts attrs["name"]
end
end
end
http_connect = Net::HTTP.new("taonix.net", 80)
resp, data = http_connect.get("/files/yp_bug2.xml", nil )
Document.parse_stream(data, Handler.new)
#Document.parse_stream((File.new "yp_bug2.xml"), Handler.new)