# Text output in rxml (builder)

**URL:** <https://www.ruby-forum.com/t/text-output-in-rxml-builder/93121>\
**Category:** Rails\
**Created:** [April 27, 2007, 9:48pm UTC](https://www.ruby-forum.com/t/text-output-in-rxml-builder/93121 "2007-04-27T21:48:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ingoweiss](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/77aa72/32.png) [@ingoweiss](https://www.ruby-forum.com/u/ingoweiss)\
**Post date:** [April 27, 2007, 9:48pm UTC](https://www.ruby-forum.com/t/text-output-in-rxml-builder/93121/1 "2007-04-27T21:48:15Z")

</div>

Hi, I need to output the following in an rxml template:

 -122.3662784465226,37.81884427772081,30 -122.3652480684771,37.81926777010555,30 -122.365640222455,37.81986126286519,30 -122.36666937925,37.81942987753481,30 -122.3662784465226,37.81884427772081,30

what I am struggling with are the text lines:

xml.coordinates do  
#what goes here?  
end

I experimented with xml.text! but I could not find a way to preserve the  
indentation and get the linebreaks

Thanks for any help!  
Ingo

---

<div class="post-metadata">

**Author:** ![ingoweiss](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/77aa72/32.png) [@ingoweiss](https://www.ruby-forum.com/u/ingoweiss)\
**Post date:** [April 28, 2007, 5:27am UTC](https://www.ruby-forum.com/t/text-output-in-rxml-builder/93121/2 "2007-04-28T05:27:43Z")

</div>

Ingo W. wrote:

> xml.coordinates do  
> #what goes here?  
> xml \<\< ‘-122…’ # right?  
> end

\<\< goes in with no translation.

> I experimented with xml.text! but I could not find a way to preserve the  
> indentation and get the linebreaks

What about xml.text! “-122…\n” ?

–  
Phlip  
[Test Driven Ajax (on Rails) [Book]](http://www.oreilly.com/catalog/9780596510657/)  
“Test Driven Ajax (on Rails)”  
assert\_xpath, assert\_javascript, & assert\_ajax

---

<div class="post-metadata">

**Author:** ![ingoweiss](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/77aa72/32.png) [@ingoweiss](https://www.ruby-forum.com/u/ingoweiss)\
**Post date:** [May 1, 2007, 3:52am UTC](https://www.ruby-forum.com/t/text-output-in-rxml-builder/93121/3 "2007-05-01T03:52:59Z")

</div>

> What about xml.text! “-122…\n” ?

This worked, but I had to manually add spaces to get the indentation  
(not that that would be terribly important, but…)

Thanks!  
Ingo

---

<div class="post-metadata">

**Author:** ![ingoweiss](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/77aa72/32.png) [@ingoweiss](https://www.ruby-forum.com/u/ingoweiss)\
**Post date:** [May 1, 2007, 5:12am UTC](https://www.ruby-forum.com/t/text-output-in-rxml-builder/93121/4 "2007-05-01T05:12:22Z")

</div>

Ingo W. wrote:

> > What about xml.text! “-122…\n” ?
> 
> This worked, but I had to manually add spaces to get the indentation  
> (not that that would be terribly important, but…)

Maybe if you use the “”" (multiline string) or \<\< (here doc) operator it  
will keep the indentation?

b

---

<div class="post-metadata">

**Author:** ![ingoweiss](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/77aa72/32.png) [@ingoweiss](https://www.ruby-forum.com/u/ingoweiss)\
**Post date:** [November 7, 2008, 9:55am UTC](https://www.ruby-forum.com/t/text-output-in-rxml-builder/93121/5 "2008-11-07T09:55:13Z")

</div>

> What about xml.text! “-122…\n” ?

I’m having an extra problem now, I’m doing this:  
xml.Data ‘ss:Type’ =\> ‘String’ do  
xml.text! format\_excel\_html(block\_content)  
end

Now it works, but the output is like this:  
  
bla bla bla

The problem I have is the whitespace the builder creates around my  
content. Does anyone know a trick to get rid of this whitespace?

Thanks, Onno
