Ruby Builder - XML ​​Output - This is an encoding of HTML objects

I have a little ruby ​​script that uses Builder.

require 'rubygems'
require 'builder'

content = <<eos
SOME TEXT, GOES TO UPPERCASE
other text
<em>italics<em>
eos

xml = Builder::XmlMarkup.new
  xml.instruct! :xml, :version => '1.0'
  xml.book :id => 1.0 do
    xml.keyPic "keyPic1.jpg"
    xml.parts do
      xml.part :partId => "1", :name => "name" do
        xml.chapter :title => "title", :subtitle => "subtitle" do
          xml.text content
        end
      end
    end
  end

p xml

When starting from the CLI (Cygwin), I get the following:

<?xml version="1.0" encoding="UTF-8"?>
<book id="1.0">
  <keyPic>keyPic1.jpg</keyPic>
    <parts>
      <part partId="1" name="name">
        <chapter title="title" subtitle="subtitle">
          <text>
          SOME TEXT, GOES TO UPPERCASE
          other text
          &lt;em&gt;italics&lt;em&gt;
          </text>
        </chapter>
      </part>
    </parts>
</book><inspect/>

However, the conclusion I would like to draw between:

<text>
SOME TEXT, GOES TO UPPERCASE
other text
<em>italics<em/>
</text>

I tried using the htmlentities gem 'decoding' content, but to no avail.

+5
source share
1 answer

Use the operation <<to insert text without changes.

xml.text do |t|
  t << content
end
+6
source

All Articles