Jesse P. wrote:
> Hi Tiziano,
> 
> My apologies. It seems that I have oversimplied the problem due to my
> lack of understanding for UTF-8.
> 
> The actual string is an xml file I obtained from flickr at
> http://api.flickr.com/services/rest/?method=flickr.people.getInfo&api_key=44dfd94b104d544f8f80b521a70429e3&user_id=55669962%40N00&api_sig=6a39aab2fb665e24d2b6e1cef9d0be27:

You have a broken utf-8 docoment (a read the Matz reply)

I see two solutions:

a)

require 'rexml/document'
require 'iconv'

data =  your xml document
data = Iconv.conv("UTF-8","ISO-8859-1",data)
doc = REXML::Document.new(data)

you must convert the data of doc from utf-8 to iso befor use it

username = Iconv.conv("ISO-8859-1","UTF-8",doc. )

b) change the encoding of the xml

require 'rexml/document'

data =  your xml document
data = data.gsub(/encoding="utf-8"/i, 'encoding="iso-8859-1"')
doc = REXML::Document.new(data)

Anyway a) and b) don't work if the document contains valid utf-8 chars 
not in ascii-7 (for example latin letters è, ò, etc.)

-- 
Posted via http://www.ruby-forum.com/.