Compress whitespace only in anchor
require 'rexml/document' text = %{<doc><a>Some whitespace</a> <b>Some more</b></doc>} REXML::Document.new(text, { :compress_whitespace => %w{a} }).to_s # => "<doc><a>Some whitespace</a> <b>Some more</b></doc>"