From: Markus Fischer Date: 2010-09-27T05:10:59+09:00 Subject: Re: Ruby, Unicode, and HTML Entities Problem Hi, On 26.09.2010 21:08, Mr Peepers wrote: > Ok, get the Ruby and a sample of the data attempting to be loaded here, > www.khourys.com/Archive.rar. > > Regarding 150340.html, as just an example. Not exactly a small test case, the 12kb load.rb . I was more talking along the line of you providing a simple script to show a reproducible error. Anyway, I simply fired up rexml to do basic thing but it bombs immediately. Disclaimer: I never used rexml before: $ ruby -rrexml/document -e 'REXML::Document.new File.new("150340.html")' /home/mfischer/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/rexml/parseexception.rb:31:in `gsub': invalid byte sequence in UTF-8 (ArgumentError) from /home/mfischer/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/rexml/parseexception.rb:31:in `to_s' from /home/mfischer/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/rexml/parsers/treeparser.rb:95:in `message' from /home/mfischer/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/rexml/parsers/treeparser.rb:95:in `rescue in parse' from /home/mfischer/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/rexml/parsers/treeparser.rb:20:in `parse' from /home/mfischer/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/rexml/document.rb:230:in `build' from /home/mfischer/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/rexml/document.rb:43:in `initialize' from -e:1:in `new' from -e:1:in `
' Anyway, the same using Nokogiri works for me: $ ruby -rnokogiri -e 'puts Nokogiri::HTML( File.open("150340.html") )/"//p/em[3]"' Ministerio P炭blico de la Federaci坦n Does that help you? If not, you should provide your *small* rexml test case which bombs. HTH, - Markus