Subscribe to The Way I See It        RSS Feed
-----

Groovy StreamingMarkupBuilder Empty Tags

Icon Leave Comment
I found something interesting today at work while playing with Groovy. By default, the StreamingMarkupBuilder builds empty tags like this:

<someTag />


but an external system that uses our API needs the tags to be expanded like this:

<someTag></someTag>


There is a very simple attribute that took me more than a few minutes to find so I wanted to share it. If you do this when configuring your StreamingMarkupBuilder object, empty tags will be expanded out:

def builder = new groovy.xml.StreamingMarkupBuilder()
builder.expandEmptyElements = true

0 Comments On This Entry

 

Trackbacks for this entry [ Trackback URL ]

There are no Trackbacks for this entry

April 2014

S M T W T F S
  12345
6789101112
13141516 17 1819
20212223242526
27282930   

Recent Entries

Recent Comments

Search My Blog

0 user(s) viewing

0 Guests
0 member(s)
0 anonymous member(s)