text = %{Some whitespace Some more}REXML::Document.new(text, { :compress_whitespace => :all, :ignore_whitespace_nodes => :all }).to_s# => "Some textSome more"