to_xhtml wrecks output. You need to use to_s or to_html here.