require 'rexml/document'text = %{Some whitespace Some more}REXML::Document.new(text, { :respect_whitespace => %w{a} }).to_s# => "Some whitespace Some more"