From: Jano Svitok Date: 2007-09-22T00:04:50+09:00 Subject: Re: Prevent REXML from doing any character decoding On 9/21/07, helzer wrote: > How can I ask REXML to NOT DO any sort of character decoding or > encoding when it processes XML files? > My files include all sorts of encoding, which is unfortunately not > recognized by REXML. I just want to process it so that all characters > are maintained exactly as they are. > > For example, Unicode HTML encoded characters (like  ) should just > stay this sequence, and not transformed into �. > > It it possible? > Can I do this without adding a character encoding line to the XML > files? > > Thanks, > Helzer http://www.germane-software.com/software/rexml/docs/tutorial.html : There is a programmatic solution: :raw. If you set the :raw flag on any Text or Element node, the entities within that node will not be processed. This means that you'll have to deal with entities yourself: Entity Replacement doc = Document.new(' ]>replace &ent;',{:raw=>:all}) doc.root.text #-> "replace &ent;" doc.to_s # Generates: # # ]>replace &ent;