# Nested tags with contents in RXML

**URL:** <https://www.ruby-forum.com/t/nested-tags-with-contents-in-rxml/92428>\
**Category:** Rails\
**Created:** [April 19, 2007, 12:44pm UTC](https://www.ruby-forum.com/t/nested-tags-with-contents-in-rxml/92428 "2007-04-19T12:44:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jean-Christophe\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/6de8d8/32.png) [@Jean-Christophe\_M](https://www.ruby-forum.com/u/Jean-Christophe_M)\
**Post date:** [April 19, 2007, 12:44pm UTC](https://www.ruby-forum.com/t/nested-tags-with-contents-in-rxml/92428/1 "2007-04-19T12:44:00Z")

</div>

Hi,

I’m trying to get

foo  
  **bar**

with RXML.

xml.a(‘foo’) {  
xml.b(‘bar’)  
}

complains about contents and blocks not being usable together.  
I think my XML is valid though. Is there a way to do this, or to trick  
RXML ?

Jean-Christophe M.

---

<div class="post-metadata">

**Author:** ![Jean-Christophe\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/6de8d8/32.png) [@Jean-Christophe\_M](https://www.ruby-forum.com/u/Jean-Christophe_M)\
**Post date:** [April 19, 2007, 8:16pm UTC](https://www.ruby-forum.com/t/nested-tags-with-contents-in-rxml/92428/2 "2007-04-19T20:16:41Z")

</div>

I think something like this should work:

xml.a {  
xml.text! ‘foo’  
xml.b(‘bar’)  
}

The text! method sets the arg as text content of the element…

b
