I have a small ruby script which 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 running 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
<em>italics<em>
</text>
</chapter>
</part>
</parts>
</book><inspect/>
However, the output I would like between is:
<text>
SOME TEXT, GOES TO UPPERCASE
other text
<em>italics<em/>
</text>
I have tried using the htmlentities gem 'decoding' the content but to no avail.
Use the <<
operation to insert your text without modification.
xml.text do |t|
t << content
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With