Search
Categories
Ad

Posts Tagged ‘xml’

REXML Error on Ruby1.9

Saturday, June 6th, 2009

Symptom

I encountered an REXML Error of

Last 80 unconsumed characters

when parsing utf-8 xml strings using REXML on Ruby1.9.1.

Solution

try check encoding

puts xmlstring.encoding #=> 'US-ASCII' in my case

If the return value is not “utf-8″, you can change the encoding as below.

xmlstring.force_encoding("utf-8")

By this change, REXML will parse the input with the correct encodings.